Bump actions/checkout from 3 to 4 #257
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: Main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*.*.*' | |
env: | |
# Change this to invalidate existing cache. | |
CACHE_PREFIX: v0 | |
PYTHONPATH: ./ | |
GANTRY_GITHUB_TESTING: 'true' | |
jobs: | |
checks: | |
name: Python ${{ matrix.python }} - ${{ matrix.task.name }} | |
runs-on: [ubuntu-latest] | |
timeout-minutes: 15 | |
env: | |
BEAKER_TOKEN: ${{ secrets.BEAKER_TOKEN }} | |
BEAKER_WORKSPACE: ai2/gantry-testing | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
strategy: | |
fail-fast: false | |
matrix: | |
python: ['3.7', '3.10.4'] | |
task: | |
- name: Test | |
run: | | |
pytest -v --color=yes tests/ | |
include: | |
- python: '3.10.4' | |
task: | |
name: Lint | |
run: ruff check . | |
- python: '3.10.4' | |
task: | |
name: Type check | |
run: mypy . | |
- python: '3.10.4' | |
task: | |
name: Build | |
run: | | |
python -m build | |
- python: '3.10.4' | |
task: | |
name: Style | |
run: | | |
isort --check . | |
black --check . | |
- python: '3.10.4' | |
task: | |
name: Example - Hello, World! | |
run: | | |
run_name=$(python conftest.py run_name) | |
gantry run \ | |
--workspace "$BEAKER_WORKSPACE" \ | |
--name "$run_name" \ | |
--timeout -1 \ | |
--yes \ | |
-- python -c 'print("Hello, World!")' | |
- python: '3.10.4' | |
task: | |
name: Example - Metrics | |
run: | | |
run_name=$(python conftest.py run_name) | |
gantry run \ | |
--workspace "$BEAKER_WORKSPACE" \ | |
--name "$run_name" \ | |
--timeout -1 \ | |
--yes \ | |
-- python examples/metrics/run.py | |
- python: '3.10.4' | |
task: | |
name: Example - Conda | |
run: | | |
run_name=$(python conftest.py run_name) | |
gantry run \ | |
--workspace "$BEAKER_WORKSPACE" \ | |
--name "$run_name" \ | |
--timeout -1 \ | |
--conda test_fixtures/conda/environment.yml \ | |
--yes \ | |
-- python --version | |
steps: | |
- name: Checkout (PR) | |
if: github.event_name == 'pull_request' | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} # check out PR head commit instead of merge commit | |
- name: Checkout (push or tag) | |
if: github.event_name != 'pull_request' | |
uses: actions/checkout@v4 | |
- name: Setup Python environment | |
uses: ./.github/actions/setup-venv | |
with: | |
python-version: ${{ matrix.python }} | |
cache-prefix: ${{ env.CACHE_PREFIX }} | |
- name: ${{ matrix.task.name }} | |
run: | | |
. .venv/bin/activate | |
${{ matrix.task.run }} | |
- name: Upload package distribution files | |
if: matrix.task.name == 'Build' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: package | |
path: dist | |
- name: Clean up | |
if: always() | |
run: | | |
. .venv/bin/activate | |
pip uninstall -y gantry | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
needs: [checks] | |
if: startsWith(github.ref, 'refs/tags/') | |
env: | |
PYPI_USERNAME: allennlp | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install requirements | |
run: | | |
pip install --upgrade pip setuptools wheel build | |
pip install -e .[dev] | |
- name: Prepare environment | |
run: | | |
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
- name: Download package distribution files | |
uses: actions/download-artifact@v3 | |
with: | |
name: package | |
path: dist | |
- name: Generate release notes | |
run: | | |
python scripts/release_notes.py > ${{ github.workspace }}-RELEASE_NOTES.md | |
- name: Publish package to PyPI | |
run: | | |
twine upload -u ${{ env.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }} dist/* | |
- name: Publish GitHub release | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
body_path: ${{ github.workspace }}-RELEASE_NOTES.md | |
prerelease: ${{ contains(env.TAG, 'rc') }} | |
files: | | |
dist/* |