From 29e9500bae9ac2aa4087640787ec6ac1a8e539ef Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Sun, 5 Mar 2023 14:15:48 -0500 Subject: [PATCH 1/2] docs: recipe for GHA generate Signed-off-by: Henry Schreiner --- docs/cookbook.rst | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/cookbook.rst b/docs/cookbook.rst index 491f5486..02b533de 100644 --- a/docs/cookbook.rst +++ b/docs/cookbook.rst @@ -131,3 +131,34 @@ Even more so with a sprinkling of Nox: session.run("git", "push", "--tags", external=True) Now a simple ``nox -s release -- patch`` will automate your release (provided you have Bump2Version set up to change your files). This is especially powerful if you have a CI/CD pipeline set up! + + +Generating a matrix with GitHub Actions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Nox knows what sessions it needs to run. Why not tell GitHub Actions what jobs to run dynamically? Using the ``--json`` flag and a bit of json processing, it's easy: + +.. code-block:: yaml + + jobs: + generate-jobs: + runs-on: ubuntu-latest + outputs: + session: ${{ steps.set-matrix.outputs.session }} + steps: + - uses: actions/checkout@v3 + - uses: wntrblm/nox@main + - id: set-matrix + run: echo session=$(nox --json -l | jq -c '[.[].session]') | tee --append $GITHUB_OUTPUT + checks: + name: Session ${{ matrix.session }} + needs: [generate-jobs] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + session: ${{ fromJson(needs.generate-jobs.outputs.session) }} + steps: + - uses: actions/checkout@v3 + - uses: wntrblm/nox@main + - run: nox -s '${{ matrix.session }}' From eafb0c3d3c3e3513cd3aef4b41a56b5e3c94f62b Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 23 Jun 2023 17:19:40 -0400 Subject: [PATCH 2/2] Update docs/cookbook.rst --- docs/cookbook.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/cookbook.rst b/docs/cookbook.rst index 02b533de..dcfb5479 100644 --- a/docs/cookbook.rst +++ b/docs/cookbook.rst @@ -149,6 +149,7 @@ Nox knows what sessions it needs to run. Why not tell GitHub Actions what jobs t - uses: actions/checkout@v3 - uses: wntrblm/nox@main - id: set-matrix + shell: bash run: echo session=$(nox --json -l | jq -c '[.[].session]') | tee --append $GITHUB_OUTPUT checks: name: Session ${{ matrix.session }}