Skip to content

Commit

Permalink
Homogenize GHA config (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Dec 6, 2023
1 parent 35ef597 commit 837e763
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 27 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
# See https://github.com/ansible/devtools/blob/main/.github/workflows/ack.yml
name: ack
"on":
pull_request_target:
types: [opened, labeled, unlabeled, synchronize]

jobs:
ack:
uses: ssbarnea/team-devtools/.github/workflows/ack.yml@main
dump_contexts_to_log:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJson(job) }}
run: echo "$JOB_CONTEXT"
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"
- name: Dump runner context
env:
RUNNER_CONTEXT: ${{ toJson(runner) }}
run: echo "$RUNNER_CONTEXT"
- name: Dump strategy context
env:
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
run: echo "$STRATEGY_CONTEXT"
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJson(matrix) }}
run: echo "$MATRIX_CONTEXT"
4 changes: 2 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
# See https://github.com/ansible-community/devtools/blob/main/.github/workflows/push.yml
# See https://github.com/ansible/team-devtools/blob/main/.github/workflows/push.yml
name: push
on:
push:
Expand All @@ -10,4 +10,4 @@ on:

jobs:
ack:
uses: ansible/devtools/.github/workflows/push.yml@main
uses: ansible/team-devtools/.github/workflows/push.yml@main
18 changes: 16 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,22 @@ name: release
"on":
release:
types: [published]
workflow_dispatch:

jobs:
# https://github.com/marketplace/actions/actions-tagger
actions-tagger:
needs: pypi # do not move the mobile tag until we publish
runs-on: windows-latest
permissions:
# Give the default GITHUB_TOKEN write permission.
# https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/
contents: write
steps:
- uses: Actions-R-Us/actions-tagger@latest
with:
token: "${{ github.token }}"
publish_latest_tag: true
pypi:
name: Publish to PyPI registry
environment: release
Expand All @@ -20,10 +34,10 @@ jobs:
TOXENV: pkg

steps:
- name: Switch to using Python 3.11 by default
- name: Switch to using Python 3.10 by default
uses: actions/setup-python@v4
with:
python-version: 3.11
python-version: "3.10"

- name: Install tox
run: python3 -m pip install --user "tox>=4.0.0"
Expand Down
82 changes: 59 additions & 23 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ on:
pull_request:

jobs:
pre:
name: pre
prepare:
name: prepare
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.generate_matrix.outputs.matrix }}
Expand All @@ -28,43 +28,79 @@ jobs:
other_names: |
lint
docs
pkg
tox:
name: ${{ matrix.name }} / python ${{ matrix.python_version }}
runs-on: ubuntu-20.04
needs: pre
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
needs:
- prepare
defaults:
run:
shell: ${{ matrix.shell || 'bash'}}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.pre.outputs.matrix) }}
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # needed by setuptools-scm
submodules: true

- name: Set up Python ${{ matrix.python_version }}
- name: Set pre-commit cache
uses: actions/cache@v3
if: ${{ matrix.passed_name == 'lint' }}
with:
path: |
~/.cache/pre-commit
key: pre-commit-${{ matrix.name || matrix.passed_name }}-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Set up Python ${{ matrix.python_version || '3.10' }}
if: "!contains(matrix.shell, 'wsl')"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
cache: pip
python-version: ${{ matrix.python_version || '3.10' }}

- name: Install tox
run: python3 -m pip install --upgrade "tox>=4.11.3"

- name: Log Python info (${{ matrix.python_version }})
run: |
command -v python
python --version --version
python3 -m pip freeze --all
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade "tox>=4.0.0"
- name: "tox -e ${{ matrix.passed_name }}"
continue-on-error: ${{ matrix.devel || false }}
- name: Log installed dists
run: python3 -m pip freeze --all

- name: Initialize tox envs ${{ matrix.passed_name }}
run: python3 -m tox --notest --skip-missing-interpreters false -vv -e ${{ matrix.passed_name }}
timeout-minutes: 5 # average is under 1, but macos can be over 3

# sequential run improves browsing experience (almost no speed impact)
- name: tox -e ${{ matrix.passed_name }}
run: python3 -m tox -e ${{ matrix.passed_name }}

tox_passed:
needs: tox
check: # This job does nothing and is only used for the branch protection
if: always()
permissions:
pull-requests: write # allow codenotify to comment on pull-request

needs:
- build

runs-on: ubuntu-latest

steps:
- run: >-
python -c "assert set([
'${{ needs.tox.result }}',
]) == {'success'}"
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

- name: Check out src from Git
uses: actions/checkout@v4

- name: Notify repository owners about lint change affecting them
uses: sourcegraph/codenotify@v0.6.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/sourcegraph/codenotify/issues/19
continue-on-error: true

0 comments on commit 837e763

Please sign in to comment.