From 6b9596d4b2e77f66abcb7545a58f30d57915a7fe Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Sat, 7 Oct 2023 08:51:27 -0700 Subject: [PATCH 1/8] Try pulling python versions from a json file --- .github/workflows/main.yml | 19 +++++++++++++++---- .python-versions.json | 4 ++++ 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 .python-versions.json diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 079730d..580cca5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,14 +2,24 @@ name: OctoDNS on: [pull_request] jobs: + config: + runs-on: ubuntu-latest + outputs: + json: ${{ steps.load.outputs.json }} + steps: + - id: load + run: | + JSON=$(cat ./.python-versions.json) + echo "::set-output name=json::${JSON}" ci: + needs: config runs-on: ubuntu-latest strategy: fail-fast: false matrix: - # Defined in an org level variable, based on dates in - # https://devguide.python.org/versions/#versions - python-version: ${{fromJson(vars.PYTHON_VERSIONS_ACTIVE)}} + # Defined in a file that resides in the top level of octodns/octodns, + # based on dates in https://devguide.python.org/versions/#versions + python-version: ${{ fromJson(needs.config.outputs.json).python_versions_active }} steps: - uses: actions/checkout@v4 - name: Setup python @@ -42,7 +52,8 @@ jobs: - name: Setup python uses: actions/setup-python@v4 with: - python-version: ${{ vars.PYTHON_VERSION_CURRENT }} + # Most recent release from https://devguide.python.org/versions/#versions + python-version: ${{ fromJson(needs.config.outputs.json).python_version_current }} architecture: x64 - name: CI setup.py run: | diff --git a/.python-versions.json b/.python-versions.json new file mode 100644 index 0000000..0e8eac4 --- /dev/null +++ b/.python-versions.json @@ -0,0 +1,4 @@ +{ + "python_version_current": "3.11", + "python_versions_active": ["3.8", "3.9", "3.10", "3.11"] +} From 32395331dcb4fb7938f68a704be874559153ae70 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Sat, 7 Oct 2023 08:59:15 -0700 Subject: [PATCH 2/8] Guess we have to checkout before we have access to files? --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 580cca5..30a8b53 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,6 +8,7 @@ jobs: json: ${{ steps.load.outputs.json }} steps: - id: load + uses: actions/checkout@v4 run: | JSON=$(cat ./.python-versions.json) echo "::set-output name=json::${JSON}" From 75d8ec53f95bf77c24bee6e138d031fe93a08091 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Sat, 7 Oct 2023 08:59:31 -0700 Subject: [PATCH 3/8] setup-py needs config too --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 30a8b53..9c5113a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,6 +47,7 @@ jobs: coverage.xml htmlcov setup-py: + needs: config runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 97e46183134c33b803adba7e67c80ff6bf06e4ef Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Sat, 7 Oct 2023 09:00:48 -0700 Subject: [PATCH 4/8] checkout needs to be its own step --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9c5113a..f0dc707 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,8 +7,8 @@ jobs: outputs: json: ${{ steps.load.outputs.json }} steps: + - uses: actions/checkout@v4 - id: load - uses: actions/checkout@v4 run: | JSON=$(cat ./.python-versions.json) echo "::set-output name=json::${JSON}" From 97d525df5b2be3008930fca67ce89a2b04f1d66c Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Sat, 7 Oct 2023 09:14:48 -0700 Subject: [PATCH 5/8] remove newlines from json --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f0dc707..73b0344 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: - id: load run: | JSON=$(cat ./.python-versions.json) - echo "::set-output name=json::${JSON}" + echo "::set-output name=json::${JSON//'%'/'%25'}" ci: needs: config runs-on: ubuntu-latest From 973fbd601e08508ce135ad33522cdd66ca24efc7 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Sat, 7 Oct 2023 09:25:23 -0700 Subject: [PATCH 6/8] try another approach for multi-line json in an output --- .github/workflows/main.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 73b0344..36608b1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,9 +9,13 @@ jobs: steps: - uses: actions/checkout@v4 - id: load + # based on https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings run: | - JSON=$(cat ./.python-versions.json) - echo "::set-output name=json::${JSON//'%'/'%25'}" + { + echo 'json<> $GITHUB_OUTPUT ci: needs: config runs-on: ubuntu-latest From 32c0b268c1da478c6c5860be1280eccb1fcc7485 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Sat, 7 Oct 2023 09:30:17 -0700 Subject: [PATCH 7/8] have modules ci job use config for python-version too --- .github/workflows/modules.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/modules.yml b/.github/workflows/modules.yml index 940abc1..1828863 100644 --- a/.github/workflows/modules.yml +++ b/.github/workflows/modules.yml @@ -5,7 +5,22 @@ on: types: [submitted] jobs: + config: + runs-on: ubuntu-latest + outputs: + json: ${{ steps.load.outputs.json }} + steps: + - uses: actions/checkout@v4 + - id: load + # based on https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings + run: | + { + echo 'json<> $GITHUB_OUTPUT ci: + needs: config runs-on: ubuntu-latest strategy: fail-fast: false @@ -46,7 +61,7 @@ jobs: - name: Setup python uses: actions/setup-python@v4 with: - python-version: ${{ vars.PYTHON_VERSION_CURRENT }} + python-version: ${{ fromJson(needs.config.outputs.json).python_version_current }} architecture: x64 - name: Test Module run: | From 9bd76c81164a576a913949da8c9af9bb77db864e Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Sat, 7 Oct 2023 09:34:46 -0700 Subject: [PATCH 8/8] more generic ci config json name --- .python-versions.json => .ci-config.json | 0 .github/workflows/main.yml | 2 +- .github/workflows/modules.yml | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename .python-versions.json => .ci-config.json (100%) diff --git a/.python-versions.json b/.ci-config.json similarity index 100% rename from .python-versions.json rename to .ci-config.json diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 36608b1..32d3181 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: run: | { echo 'json<> $GITHUB_OUTPUT ci: diff --git a/.github/workflows/modules.yml b/.github/workflows/modules.yml index 1828863..9d6e767 100644 --- a/.github/workflows/modules.yml +++ b/.github/workflows/modules.yml @@ -16,7 +16,7 @@ jobs: run: | { echo 'json<> $GITHUB_OUTPUT ci: