Bump actions/checkout from 1 to 4 #196
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 }} | |
cancel-in-progress: true | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*.*.*' | |
env: | |
# Change this to invalidate existing cache. | |
CACHE_PREFIX: v0 | |
PYTHON_PATH: ./ | |
jobs: | |
test_action: | |
name: Action (${{ matrix.task.name }}) | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
strategy: | |
fail-fast: false | |
matrix: | |
task: | |
- name: JSON spec | |
spec: | | |
{ | |
"version": "v2", | |
"description": "Hello, World!", | |
"tasks": [ | |
{ | |
"name": "hello", | |
"image": {"docker": "hello-world"}, | |
"context": {"cluster": "ai2/petew-cpu"}, | |
"result": {"path": "/unused"} | |
} | |
] | |
} | |
- name: YAML spec | |
spec: | | |
version: "v2" | |
description: "Hello, World!" | |
tasks: | |
- name: "hello" | |
image: | |
docker: "hello-world" | |
context: | |
cluster: "ai2/petew-cpu" | |
result: | |
path: "/unused" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Test action | |
uses: ./ | |
with: | |
spec: ${{ matrix.task.spec }} | |
token: ${{ secrets.BEAKER_TOKEN }} | |
workspace: ai2/petew-testing | |
clusters: ai2/general-cirrascale,ai2/allennlp-cirrascale | |
checks: | |
name: Python ${{ matrix.python }} - ${{ matrix.task.name }} | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
strategy: | |
fail-fast: false | |
matrix: | |
python: ['3.10'] | |
task: | |
- name: Lint | |
run: flake8 . | |
- name: Type check | |
run: mypy . | |
- name: Style | |
run: black --check . | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python }} | |
- name: Install prerequisites | |
run: | | |
pip install --upgrade pip setuptools wheel virtualenv | |
- name: Set build variables | |
shell: bash | |
run: | | |
# Get the exact Python version to use in the cache key. | |
echo "PYTHON_VERSION=$(python --version)" >> $GITHUB_ENV | |
echo "RUNNER_ARCH=$(uname -m)" >> $GITHUB_ENV | |
# Use week number in cache key so we can refresh the cache weekly. | |
echo "WEEK_NUMBER=$(date +%V)" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
id: virtualenv-cache | |
with: | |
path: .venv | |
key: ${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('dev-requirements.txt') }} | |
restore-keys: | | |
${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-${{ env.PYTHON_VERSION }}- | |
- name: Setup virtual environment (no cache hit) | |
if: steps.virtualenv-cache.outputs.cache-hit != 'true' | |
run: | | |
test -d .venv || virtualenv -p $(which python) --copies --reset-app-data .venv | |
. .venv/bin/activate | |
pip install -r requirements.txt -r dev-requirements.txt | |
- name: Show environment info | |
run: | | |
. .venv/bin/activate | |
which python | |
python --version | |
pip freeze | |
- name: ${{ matrix.task.name }} | |
run: | | |
. .venv/bin/activate | |
${{ matrix.task.run }} | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
needs: [test_action, checks] | |
if: startsWith(github.ref, 'refs/tags/') | |
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 | |
pip install -r dev-requirements.txt | |
- name: Prepare environment | |
run: | | |
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
- name: Generate release notes | |
run: | | |
python scripts/release_notes.py > ${{ github.workspace }}-RELEASE_NOTES.md | |
- 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') }} |