Skip to content

Commit

Permalink
GHA release workflow, refactor PR and Daily workflows (#1968)
Browse files Browse the repository at this point in the history
  • Loading branch information
bandish-shah authored Feb 22, 2023
1 parent ddf179c commit 2d9053b
Show file tree
Hide file tree
Showing 11 changed files with 461 additions and 299 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: PyTest Coverage
on:
workflow_call:
inputs:
download-path:
required: true
type: string
jobs:
coverage:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup
run: |
set -ex
python -m pip install --upgrade 'pip<23' wheel
pip install coverage[toml]==6.5.0
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ${{ inputs.download-path }}
- name: Generate coverage report
run: |
set -ex
# Flatten the coverage files
ls ${{ inputs.download-path }} | while read x; do mv ${{ inputs.download-path }}/$x/.coverage .coverage.$x; done
python -m coverage combine
python -m coverage report
132 changes: 34 additions & 98 deletions .github/workflows/pytest-daily.yaml → .github/workflows/daily.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pytest-Daily
name: Daily
on:
schedule:
- cron: '30 2 * * *' # 2:30 every day
Expand All @@ -7,19 +7,15 @@ on:
- dev
- main
- release/**
workflow_call:
workflow_dispatch:
# Cancel old runs when a new commit is pushed to the same branch if not on main or dev
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}
jobs:
pytest-cpu:
timeout-minutes: 45
runs-on: ubuntu-20.04
if: github.repository_owner == 'mosaicml'
daily-pytest-cpu:
uses: ./.github/workflows/pytest-cpu.yaml
strategy:
fail-fast: false
matrix:
include:
- name: 'cpu-3.8-1.11'
Expand Down Expand Up @@ -63,71 +59,31 @@ jobs:
markers: 'daily and (remote or not remote) and not gpu and not vision and doctest'
pytest_command: 'coverage run -m pytest tests/test_docs.py'
name: ${{ matrix.name }}
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@v2
- name: Setup
run: |
set -ex
export PATH=/composer-python:$PATH
python -m pip install --upgrade 'pip<23' wheel
python -m pip install --upgrade .[all]
- name: Run Tests
id: tests
run: |
set -ex
export PATH=/composer-python:$PATH
export WANDB_API_KEY='${{ secrets.WANDB_API_KEY }}'
export WANDB_ENTITY='mosaicml-public-integration-tests'
export WANDB_PROJECT="integration-tests-${{ github.sha }}"
export AWS_ACCESS_KEY_ID='${{ secrets.AWS_ACCESS_KEY_ID }}'
export AWS_SECRET_ACCESS_KEY='${{ secrets.AWS_SECRET_ACCESS_KEY }}'
export S3_BUCKET='mosaicml-internal-integration-testing'
export COMMON_ARGS="-v --durations=20 -m '${{ matrix.markers }}' --s3_bucket '$S3_BUCKET'"
# Necessary to run git diff for doctests
git config --global --add safe.directory /__w/composer/composer
make test PYTEST='${{ matrix.pytest_command }}' EXTRA_ARGS="$COMMON_ARGS --codeblocks"
make test-dist PYTEST='${{ matrix.pytest_command }}' EXTRA_ARGS="$COMMON_ARGS" WORLD_SIZE=2
python -m coverage combine
- uses: actions/upload-artifact@v3
with:
name: coverage-${{ github.sha }}-${{ matrix.name }}
path: .coverage
if: github.repository_owner == 'mosaicml'
with:
container: ${{ matrix.container }}
name: ${{ matrix.name }}
pytest-command: ${{ matrix.pytest_command }}
pytest-markers: ${{ matrix.markers }}
pytest-s3-bucket: 'mosaicml-internal-integration-testing'
python-version: 3.9
pytest-wandb-entity: 'mosaicml-public-integration-tests'
pytest-wandb-project: "integration-tests-${{ github.sha }}"
secrets:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
wandb-api-key: ${{ secrets.WANDB_API_KEY }}
coverage:
needs: [ pytest-cpu ]
timeout-minutes: 30
runs-on: ubuntu-20.04
uses: ./.github/workflows/coverage.yaml
name: Coverage Results
if: github.repository_owner == 'mosaicml'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup
run: |
set -ex
python -m pip install --upgrade 'pip<23' wheel
pip install coverage[toml]==6.5.0
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Generate coverage report
run: |
set -ex
# Flatten the coverage files
ls artifacts | while read x; do mv artifacts/$x/.coverage .coverage.$x; done
needs: [ daily-pytest-cpu ]
with:
download-path: artifacts

python -m coverage combine
python -m coverage report
pytest-gpu:
timeout-minutes: 45
runs-on: ubuntu-20.04
if: github.repository_owner == 'mosaicml'
daily-pytest-gpu:
uses: ./.github/workflows/pytest-gpu.yaml
strategy:
fail-fast: false
matrix:
# Unlike CPU tests, we run daily tests together with GPU tests to minimize launch time
# on MCLOUD and not eat up all GPUs at once
Expand All @@ -149,33 +105,13 @@ jobs:
markers: '(daily or not daily) and (remote or not remote) and gpu and (vision or doctest)'
pytest_command: 'coverage run -m pytest'
name: ${{ matrix.name }}
env:
MOSAICML_API_KEY: ${{ secrets.MCLOUD_API_KEY }}
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Cache pip
uses: actions/cache@v2
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Setup MCLI
run: |
set -ex
python -m pip install --upgrade mosaicml-cli
mcli init --mcloud
mcli version
- name: Submit Run
id: tests
run: |
set -ex
python .github/mcp/mcp_pytest.py --image '${{ matrix.container }}' --git_commit $GITHUB_SHA --pytest_markers '${{ matrix.markers }}' --pytest_command '${{ matrix.pytest_command }}'
if: github.repository_owner == 'mosaicml'
with:
container: ${{ matrix.container }}
mcloud-timeout: 1800
name: ${{ matrix.name }}
pytest-command: ${{ matrix.pytest_command }}
pytest-markers: ${{ matrix.markers }}
python-version: 3.9
secrets:
mcloud-api-key: ${{ secrets.MCLOUD_API_KEY }}
100 changes: 0 additions & 100 deletions .github/workflows/docker-build.yaml

This file was deleted.

87 changes: 87 additions & 0 deletions .github/workflows/docker-configure-build-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Docker Image Configure-Build-Push
on:
workflow_call:
inputs:
build-args:
required: false
type: string
context:
required: true
type: string
image-name:
required: true
type: string
image-uuid:
required: false
type: string
push:
required: true
type: boolean
staging:
required: true
type: boolean
staging-repo:
required: false
type: string
tags:
required: true
type: string
target:
required: false
type: string
secrets:
username:
required: true
password:
required: true
jobs:
configure-build-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.username }}
password: ${{ secrets.password }}

- name: Calculate Docker Image Variables
run: |
set -euo pipefail
###################
# Calculate the tag
###################
if [ "${{ inputs.staging }}" = "true" ]; then
STAGING_REPO=${{ inputs.staging-repo }}
IMAGE_TAG=${STAGING_REPO}:${{ inputs.image-uuid }}
IMAGE_CACHE="${STAGING_REPO}:${{ inputs.image-name }}-buildcache"
else
IMAGE_TAG=${{ inputs.tags }}
IMAGE_CACHE="${IMAGE_TAG/,*/}-buildcache"
fi
echo "IMAGE_TAG=${IMAGE_TAG}" >> ${GITHUB_ENV}
echo "IMAGE_CACHE=${IMAGE_CACHE}" >> ${GITHUB_ENV}
- name: IMAGE_TAG = ${{ env.IMAGE_TAG }}
run: echo ${{ env.IMAGE_TAG }}

- name: Build and Push the Docker Image
uses: docker/build-push-action@v3
with:
context: ${{ inputs.context }}
tags: ${{ env.IMAGE_TAG }}
target: ${{ inputs.target }}
push: ${{ inputs.push }}
cache-from: type=registry,ref=${{ env.IMAGE_CACHE }}
cache-to: type=registry,ref=${{ env.IMAGE_CACHE }},mode=max
build-args: ${{ inputs.build-args }}
Loading

0 comments on commit 2d9053b

Please sign in to comment.