Test and Release #1324
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test and Release | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
paths: | |
- 'src/**' | |
- 'tests/**' | |
schedule: | |
# every weekday at 17:00 UTC | |
- cron: '0 17 * * 1-5' | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
- name: Install Dependencies | |
run: pip install tox | |
- name: Flake8 | |
run: tox -e flake8 | |
- name: Black Check | |
run: tox -e black-check | |
- name: Pylint | |
run: tox -e pylint | |
- name: Docstyle | |
run: tox -e docstyle | |
- name: Doc Generation | |
run: tox -e docs | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Python 3.7 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.7' | |
- name: Setup Python 3.8 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.8' | |
- name: Setup Python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Setup Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Setup Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Install Dependencies | |
run: pip install tox | |
# runs unit tests for each python version | |
- name: Unit Tests | |
run: tox -- tests/unit | |
env: | |
AWS_DEFAULT_REGION: us-west-2 | |
- name: Integration Tests | |
# pull requests are untrusted and do not have access to secrets needed for integ tests | |
if: github.event_name != 'pull_request' | |
run: tox -e py39 -- tests/integ | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: us-west-2 | |
COVERAGE_FILE: .coverage.integ | |
IGNORE_COVERAGE: '-' | |
- name: Upload Code Coverage | |
if: github.event_name == 'schedule' | |
run: tox -e upload-coverage | |
env: | |
CODECOV_UPLOAD_TOKEN: ${{ secrets.CODECOV_UPLOAD_TOKEN }} | |
release: | |
needs: [test, lint] | |
if: github.event_name == 'schedule' && github.repository == 'aws/sagemaker-experiments' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install Dependencies | |
run: pip install setuptools wheel twine tox | |
- name: Create Release | |
run: tox -e release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Distribution | |
run: python setup.py bdist_wheel | |
- name: Twine Check | |
run: twine check dist/* | |
- name: Publish to Test PyPi | |
run: twine upload dist/* | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/ | |
- name: Publish to PyPi | |
run: twine upload dist/* | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |