|
| 1 | +name: Test and Release |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + release: |
| 8 | + types: [published] |
| 9 | + push: |
| 10 | + paths: |
| 11 | + - 'src/**' |
| 12 | + - 'tests/**' |
| 13 | + |
| 14 | +jobs: |
| 15 | + lint: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v1 |
| 19 | + - name: Setup Python |
| 20 | + uses: actions/setup-python@v1 |
| 21 | + - name: Install Dependencies |
| 22 | + run: pip install tox |
| 23 | + - name: Flake8 |
| 24 | + run: tox -e flake8 |
| 25 | + - name: Black Check |
| 26 | + run: tox -e black-check |
| 27 | + - name: Pylint |
| 28 | + run: tox -e pylint |
| 29 | + |
| 30 | + test: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v1 |
| 34 | + - name: Setup Python 3.5 |
| 35 | + uses: actions/setup-python@v1 |
| 36 | + with: |
| 37 | + python-version: 3.5 |
| 38 | + - name: Setup Python 3.6 |
| 39 | + uses: actions/setup-python@v1 |
| 40 | + with: |
| 41 | + python-version: 3.6 |
| 42 | + - name: Setup Python 3.7 |
| 43 | + uses: actions/setup-python@v1 |
| 44 | + with: |
| 45 | + python-version: 3.7 |
| 46 | + - name: Install Dependencies |
| 47 | + run: pip install tox |
| 48 | + # runs unit tests for each python version |
| 49 | + - name: Unit Tests |
| 50 | + run: tox -- tests/unit |
| 51 | + env: |
| 52 | + AWS_DEFAULT_REGION: us-west-2 |
| 53 | + - name: Integration Tests |
| 54 | + # pull requests are untrusted and do not have access to secrets needed for integ tests |
| 55 | + if: github.event_name != 'pull_request' |
| 56 | + run: tox -e py36 -- tests/integ |
| 57 | + env: |
| 58 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 59 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 60 | + AWS_DEFAULT_REGION: us-west-2 |
| 61 | + COVERAGE_FILE: .coverage.integ |
| 62 | + IGNORE_COVERAGE: '-' |
| 63 | + - name: Upload Code Coverage |
| 64 | + if: github.event_name == 'release' |
| 65 | + run: | |
| 66 | + coverage combine .coverage* |
| 67 | + codecov -t {env:CODECOV_UPLOAD_TOKEN} |
| 68 | + env: |
| 69 | + CODECOV_UPLOAD_TOKEN: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 70 | + |
| 71 | + release: |
| 72 | + needs: [test, lint] |
| 73 | + if: github.event_name == 'release' && github.repository == 'aws/sagemaker-experiments' |
| 74 | + runs-on: ubuntu-latest |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v1 |
| 77 | + - name: Setup Python |
| 78 | + uses: actions/setup-python@v1 |
| 79 | + with: |
| 80 | + python-version: '3.x' |
| 81 | + - name: Install Dependencies |
| 82 | + run: pip install setuptools wheel twine tox |
| 83 | + - name: Create Distribution |
| 84 | + run: python setup.py bdist_wheel |
| 85 | + - name: Sign Release |
| 86 | + run: | |
| 87 | + echo "${{ secrets.PYPI_SIGN_PRIVATE_KEY }}" | gpg --batch --import --no-default-keyring --keyring ./sessionring.gpg |
| 88 | + gpg --no-default-keyring --keyring ./sessionring.gpg --pinentry-mode loopback --passphrase ""${{ secrets.PYPI_SIGN_PASSPHRASE }}"" --detach-sign -ao /dev/null dist/* |
| 89 | + - name: Twine Check |
| 90 | + run: twine check dist/* |
| 91 | + - name: Publish to Test PyPi |
| 92 | + run: twine upload dist/* |
| 93 | + env: |
| 94 | + TWINE_USERNAME: __token__ |
| 95 | + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 96 | + TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/ |
| 97 | + - name: Publish to PyPi |
| 98 | + run: twine upload dist/* |
| 99 | + env: |
| 100 | + TWINE_USERNAME: __token__ |
| 101 | + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments