From 9b84c1705cac23cb307a4a51139ce9cd045a5af2 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Fri, 16 Aug 2024 13:17:46 +0000 Subject: [PATCH 01/37] feat: Add Python testing --- .github/workflows/python-testing.yml | 76 ++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/python-testing.yml diff --git a/.github/workflows/python-testing.yml b/.github/workflows/python-testing.yml new file mode 100644 index 0000000..b36ee77 --- /dev/null +++ b/.github/workflows/python-testing.yml @@ -0,0 +1,76 @@ +# Python Testing Workflow +# +# - Automatically runs tests on all supported versions of Python +name: Python - Testing + +on: + pull_request: + workflow_call: + inputs: + versions: + description: 'Python versions to test against' + type: string + # All Major versions of Python that are currently supported + default: '3.9,3.10,3.11,3.12' + +jobs: + python-verions: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Set matrix + id: set-matrix + run: | + versions=${{ github.event.inputs.versions }} + matrix=$(echo $versions | tr "," "\n" | sed 's/^//' | sed 's/$/"/' | tr "\n" "," | sed 's/,$//') + echo "::set-output name=matrix::$matrix" + + python-testing: + # This workflow runs on the latest version of Ubuntu + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ${{ fromJson(steps.python-verions.outputs.matrix) }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + set -e + + if [[ -f pyproject.toml ]]; then + python -m pip install --upgrade pip poetry + poetry install + elif [[ -f Pipfile ]]; then + python -m pip install --upgrade pip pipenv + pipenv sync -d + elif [[ -f requirements.txt ]]; then + python -m pip install --upgrade pip + pip install -r requirements.txt + elif [[ -f Makefile ]]; then + make install + else + echo "No manifest files found to install dependencies" + fi + + - name: Run tests + run: | + set -e + if [[ -f pyproject.toml ]]; then + poetry run test + elif [[ -f Pipfile ]]; then + pipenv run test + elif [[ -f Makefile ]]; then + make test + else + pytest + fi From 59ed01cb67e34aa163e776a590796783e2902318 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Fri, 16 Aug 2024 13:34:53 +0000 Subject: [PATCH 02/37] feat: Update testing and add scripts --- .github/workflows/python-testing.yml | 29 +++------------------------- scripts/install.sh | 23 ++++++++++++++++++++++ scripts/testing.sh | 18 +++++++++++++++++ 3 files changed, 44 insertions(+), 26 deletions(-) create mode 100755 scripts/install.sh create mode 100755 scripts/testing.sh diff --git a/.github/workflows/python-testing.yml b/.github/workflows/python-testing.yml index b36ee77..45418ba 100644 --- a/.github/workflows/python-testing.yml +++ b/.github/workflows/python-testing.yml @@ -45,32 +45,9 @@ jobs: - name: Install dependencies run: | - set -e - - if [[ -f pyproject.toml ]]; then - python -m pip install --upgrade pip poetry - poetry install - elif [[ -f Pipfile ]]; then - python -m pip install --upgrade pip pipenv - pipenv sync -d - elif [[ -f requirements.txt ]]; then - python -m pip install --upgrade pip - pip install -r requirements.txt - elif [[ -f Makefile ]]; then - make install - else - echo "No manifest files found to install dependencies" - fi + ./${{ github.action_path }}/script/install.sh "python" - name: Run tests run: | - set -e - if [[ -f pyproject.toml ]]; then - poetry run test - elif [[ -f Pipfile ]]; then - pipenv run test - elif [[ -f Makefile ]]; then - make test - else - pytest - fi + + ./${{ github.action_path }}/script/testing.sh "python" diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100755 index 0000000..f53ae9d --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +LANGUAGE=${LANGUAGE:-"python"} + +if [[ "$LANGUAGE" == "python" ]]; then + echo "Installing Python dependencies..." + + if [[ -f pyproject.toml ]]; then + python -m pip install --upgrade pip poetry + poetry install + elif [[ -f Pipfile ]]; then + python -m pip install --upgrade pip pipenv + pipenv sync -d + elif [[ -f requirements.txt ]]; then + python -m pip install --upgrade pip + pip install -r requirements.txt + elif [[ -f Makefile ]]; then + make install + else + echo "No manifest files found to install dependencies" + fi +fi \ No newline at end of file diff --git a/scripts/testing.sh b/scripts/testing.sh new file mode 100755 index 0000000..73fe305 --- /dev/null +++ b/scripts/testing.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -e + +LANGUAGE=${LANGUAGE:-"python"} + +if [[ "$LANGUAGE" == "python" ]]; then + echo "Testing Python dependencies..." + + if [[ -f pyproject.toml ]]; then + poetry run test + elif [[ -f Pipfile ]]; then + pipenv run test + elif [[ -f Makefile ]]; then + make test + else + pytest + fi +fi \ No newline at end of file From a943337eeec2b74d88ea5fdcc5c11e8a93e45218 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Fri, 16 Aug 2024 13:35:10 +0000 Subject: [PATCH 03/37] feat: Add initial linting support --- .github/workflows/python-linting.yml | 57 ++++++++++++++++++++++++++++ scripts/linting.sh | 19 ++++++++++ 2 files changed, 76 insertions(+) create mode 100644 .github/workflows/python-linting.yml create mode 100755 scripts/linting.sh diff --git a/.github/workflows/python-linting.yml b/.github/workflows/python-linting.yml new file mode 100644 index 0000000..a971ba1 --- /dev/null +++ b/.github/workflows/python-linting.yml @@ -0,0 +1,57 @@ +# Python Testing Workflow +# +# - Automatically runs tests on all supported versions of Python +name: Python - Linting + +on: + pull_request: + workflow_call: + inputs: + tool: + description: 'The tool to lint with' + type: string + default: 'ruff' + versions: + description: 'Python versions to test against' + type: string + # All Major versions of Python that are currently supported + default: '3.9,3.10,3.11,3.12' + +jobs: + python-verions: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Set matrix + id: set-matrix + run: | + versions=${{ github.event.inputs.versions }} + matrix=$(echo $versions | tr "," "\n" | sed 's/^//' | sed 's/$/"/' | tr "\n" "," | sed 's/,$//') + echo "::set-output name=matrix::$matrix" + + + python-linting: + # This workflow runs on the latest version of Ubuntu + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ${{ fromJson(steps.python-verions.outputs.matrix) }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + ./${{ github.action_path }}/script/install.sh "python" + + - name: Run linting + run: | + ./${{ github.action_path }}/script/install.sh "python" "${{ github.event.inputs.tool }}" diff --git a/scripts/linting.sh b/scripts/linting.sh new file mode 100755 index 0000000..a121884 --- /dev/null +++ b/scripts/linting.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +LANGUAGE=${1:-"python"} +TOOL=${2:-"ruff"} + +if [[ "$LANGUAGE" == "python" ]]; then + echo "Linting Python..." + + if [[ "$TOOL" == "ruff" ]]; then + pip install ruff + ruff check + elif [[ "$TOOL" == "flake8" ]]; then + pip install flake8 + flake8 . + elif [[ "$TOOL" == "black" ]]; then + pip install black + black --check . + fi +fi From d598602a141c48a6d6a521ed50fd02b86347dfd6 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Fri, 16 Aug 2024 13:40:39 +0000 Subject: [PATCH 04/37] fix: Update matrix steps --- .github/workflows/python-linting.yml | 4 ++-- .github/workflows/python-testing.yml | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-linting.yml b/.github/workflows/python-linting.yml index a971ba1..2dccbfe 100644 --- a/.github/workflows/python-linting.yml +++ b/.github/workflows/python-linting.yml @@ -32,12 +32,12 @@ jobs: python-linting: - # This workflow runs on the latest version of Ubuntu runs-on: ubuntu-latest + if: ${{ needs.python-verions.outputs.matrix != '[]' }} strategy: fail-fast: false matrix: - python-version: ${{ fromJson(steps.python-verions.outputs.matrix) }} + python-version: ${{ fromJson(needs.python-verions.outputs.matrix) }} steps: - name: Checkout diff --git a/.github/workflows/python-testing.yml b/.github/workflows/python-testing.yml index 45418ba..e6aadcf 100644 --- a/.github/workflows/python-testing.yml +++ b/.github/workflows/python-testing.yml @@ -29,10 +29,11 @@ jobs: python-testing: # This workflow runs on the latest version of Ubuntu runs-on: ubuntu-latest + if: ${{ needs.python-verions.outputs.matrix != '[]' }} strategy: fail-fast: false matrix: - python-version: ${{ fromJson(steps.python-verions.outputs.matrix) }} + python-version: ${{ fromJson(needs.python-verions.outputs.matrix) }} steps: - name: Checkout From 601181fcc9ef73c5f9df20536535f0f6d8c0862e Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Fri, 16 Aug 2024 13:44:17 +0000 Subject: [PATCH 05/37] fix: Set Matrix issue --- .github/workflows/python-linting.yml | 5 ++--- .github/workflows/python-testing.yml | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-linting.yml b/.github/workflows/python-linting.yml index 2dccbfe..016326a 100644 --- a/.github/workflows/python-linting.yml +++ b/.github/workflows/python-linting.yml @@ -26,10 +26,9 @@ jobs: - name: Set matrix id: set-matrix run: | - versions=${{ github.event.inputs.versions }} + versions="${{ github.event.inputs.versions }}" matrix=$(echo $versions | tr "," "\n" | sed 's/^//' | sed 's/$/"/' | tr "\n" "," | sed 's/,$//') - echo "::set-output name=matrix::$matrix" - + echo "name=matrix::$matrix" >> "$GITHUB_OUTPUT" python-linting: runs-on: ubuntu-latest diff --git a/.github/workflows/python-testing.yml b/.github/workflows/python-testing.yml index e6aadcf..efb76e9 100644 --- a/.github/workflows/python-testing.yml +++ b/.github/workflows/python-testing.yml @@ -22,9 +22,9 @@ jobs: - name: Set matrix id: set-matrix run: | - versions=${{ github.event.inputs.versions }} + versions="${{ github.event.inputs.versions }}" matrix=$(echo $versions | tr "," "\n" | sed 's/^//' | sed 's/$/"/' | tr "\n" "," | sed 's/,$//') - echo "::set-output name=matrix::$matrix" + echo "name=matrix::$matrix" >> "$GITHUB_OUTPUT" python-testing: # This workflow runs on the latest version of Ubuntu From 344afd7915f3d54450538f8242e9c29521f5ffc8 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Fri, 16 Aug 2024 13:49:35 +0000 Subject: [PATCH 06/37] fix: Update set matrix script --- .github/workflows/python-linting.yml | 6 ++++-- .github/workflows/python-testing.yml | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python-linting.yml b/.github/workflows/python-linting.yml index 016326a..68b5262 100644 --- a/.github/workflows/python-linting.yml +++ b/.github/workflows/python-linting.yml @@ -27,8 +27,10 @@ jobs: id: set-matrix run: | versions="${{ github.event.inputs.versions }}" - matrix=$(echo $versions | tr "," "\n" | sed 's/^//' | sed 's/$/"/' | tr "\n" "," | sed 's/,$//') - echo "name=matrix::$matrix" >> "$GITHUB_OUTPUT" + echo "Version Input :: $versions" + matrix=$(echo "$versions" | tr "," "\n" | awk '{print "\""$1"\""}' | paste -sd "," -) + echo "matrix :: [$matrix]" + echo "name=matrix::[$matrix]" >> "$GITHUB_OUTPUT" python-linting: runs-on: ubuntu-latest diff --git a/.github/workflows/python-testing.yml b/.github/workflows/python-testing.yml index efb76e9..e1cc6fd 100644 --- a/.github/workflows/python-testing.yml +++ b/.github/workflows/python-testing.yml @@ -24,7 +24,10 @@ jobs: run: | versions="${{ github.event.inputs.versions }}" matrix=$(echo $versions | tr "," "\n" | sed 's/^//' | sed 's/$/"/' | tr "\n" "," | sed 's/,$//') - echo "name=matrix::$matrix" >> "$GITHUB_OUTPUT" + echo "Version Input :: $versions" + matrix=$(echo "$versions" | tr "," "\n" | awk '{print "\""$1"\""}' | paste -sd "," -) + echo "matrix :: [$matrix]" + echo "name=matrix::[$matrix]" >> "$GITHUB_OUTPUT" python-testing: # This workflow runs on the latest version of Ubuntu From 14651b54603a7cfea1fc58058af64c989a22d82c Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Fri, 16 Aug 2024 13:50:10 +0000 Subject: [PATCH 07/37] feat: add needs to jobs --- .github/workflows/python-linting.yml | 1 + .github/workflows/python-testing.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/python-linting.yml b/.github/workflows/python-linting.yml index 68b5262..98b9b39 100644 --- a/.github/workflows/python-linting.yml +++ b/.github/workflows/python-linting.yml @@ -35,6 +35,7 @@ jobs: python-linting: runs-on: ubuntu-latest if: ${{ needs.python-verions.outputs.matrix != '[]' }} + needs: [ python-verions ] strategy: fail-fast: false matrix: diff --git a/.github/workflows/python-testing.yml b/.github/workflows/python-testing.yml index e1cc6fd..0a73627 100644 --- a/.github/workflows/python-testing.yml +++ b/.github/workflows/python-testing.yml @@ -33,6 +33,7 @@ jobs: # This workflow runs on the latest version of Ubuntu runs-on: ubuntu-latest if: ${{ needs.python-verions.outputs.matrix != '[]' }} + needs: [ python-verions ] strategy: fail-fast: false matrix: From 19c37b790fbfcece8d849435c54994c82f038e79 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Fri, 16 Aug 2024 13:52:41 +0000 Subject: [PATCH 08/37] fix: Update inputs --- .github/workflows/python-testing.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/python-testing.yml b/.github/workflows/python-testing.yml index 0a73627..ac65efa 100644 --- a/.github/workflows/python-testing.yml +++ b/.github/workflows/python-testing.yml @@ -22,8 +22,7 @@ jobs: - name: Set matrix id: set-matrix run: | - versions="${{ github.event.inputs.versions }}" - matrix=$(echo $versions | tr "," "\n" | sed 's/^//' | sed 's/$/"/' | tr "\n" "," | sed 's/,$//') + versions="${{ inputs.versions }}" echo "Version Input :: $versions" matrix=$(echo "$versions" | tr "," "\n" | awk '{print "\""$1"\""}' | paste -sd "," -) echo "matrix :: [$matrix]" From d1946162fc9bea2e6830ef3b8ad2a2457a031086 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Fri, 16 Aug 2024 14:00:50 +0000 Subject: [PATCH 09/37] fix: Update typo --- .github/workflows/python-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-testing.yml b/.github/workflows/python-testing.yml index ac65efa..ec9f8ae 100644 --- a/.github/workflows/python-testing.yml +++ b/.github/workflows/python-testing.yml @@ -36,7 +36,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ${{ fromJson(needs.python-verions.outputs.matrix) }} + python-version: ${{ fromJSON(needs.python-verions.outputs.matrix) }} steps: - name: Checkout From 1f49e688c925c127aa970fd2064fdbbf256a7002 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Fri, 16 Aug 2024 14:25:28 +0000 Subject: [PATCH 10/37] fix: Update output --- .github/workflows/python-testing.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/python-testing.yml b/.github/workflows/python-testing.yml index ec9f8ae..a86b878 100644 --- a/.github/workflows/python-testing.yml +++ b/.github/workflows/python-testing.yml @@ -26,7 +26,7 @@ jobs: echo "Version Input :: $versions" matrix=$(echo "$versions" | tr "," "\n" | awk '{print "\""$1"\""}' | paste -sd "," -) echo "matrix :: [$matrix]" - echo "name=matrix::[$matrix]" >> "$GITHUB_OUTPUT" + echo "matrix=[$matrix]" >> "$GITHUB_OUTPUT" python-testing: # This workflow runs on the latest version of Ubuntu @@ -53,5 +53,4 @@ jobs: - name: Run tests run: | - ./${{ github.action_path }}/script/testing.sh "python" From 5cfc574618d346d1e5118b589dc588ac6e954653 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Fri, 16 Aug 2024 14:52:13 +0000 Subject: [PATCH 11/37] feat: Update and in-line again --- .github/workflows/python-linting.yml | 33 ++++++++++++++++++++++++---- .github/workflows/python-testing.yml | 27 +++++++++++++++++++++-- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-linting.yml b/.github/workflows/python-linting.yml index 98b9b39..c56fcce 100644 --- a/.github/workflows/python-linting.yml +++ b/.github/workflows/python-linting.yml @@ -26,11 +26,11 @@ jobs: - name: Set matrix id: set-matrix run: | - versions="${{ github.event.inputs.versions }}" + versions="${{ inputs.versions }}" echo "Version Input :: $versions" matrix=$(echo "$versions" | tr "," "\n" | awk '{print "\""$1"\""}' | paste -sd "," -) echo "matrix :: [$matrix]" - echo "name=matrix::[$matrix]" >> "$GITHUB_OUTPUT" + echo "matrix=[$matrix]" >> "$GITHUB_OUTPUT" python-linting: runs-on: ubuntu-latest @@ -52,8 +52,33 @@ jobs: - name: Install dependencies run: | - ./${{ github.action_path }}/script/install.sh "python" + set -e + if [[ -f pyproject.toml ]]; then + python -m pip install --upgrade pip poetry + poetry install + elif [[ -f Pipfile ]]; then + python -m pip install --upgrade pip pipenv + pipenv sync -d + elif [[ -f requirements.txt ]]; then + python -m pip install --upgrade pip + pip install -r requirements.txt + elif [[ -f Makefile ]]; then + make install + else + echo "No manifest files found to install dependencies" + fi - name: Run linting run: | - ./${{ github.action_path }}/script/install.sh "python" "${{ github.event.inputs.tool }}" + set -e + TOOL="${{ inputs.tool }}" + if [[ "$TOOL" == "ruff" ]]; then + pip install ruff + ruff check + elif [[ "$TOOL" == "flake8" ]]; then + pip install flake8 + flake8 . + elif [[ "$TOOL" == "black" ]]; then + pip install black + black --check . + fi diff --git a/.github/workflows/python-testing.yml b/.github/workflows/python-testing.yml index a86b878..bcd11f4 100644 --- a/.github/workflows/python-testing.yml +++ b/.github/workflows/python-testing.yml @@ -49,8 +49,31 @@ jobs: - name: Install dependencies run: | - ./${{ github.action_path }}/script/install.sh "python" + set -e + if [[ -f pyproject.toml ]]; then + python -m pip install --upgrade pip poetry + poetry install + elif [[ -f Pipfile ]]; then + python -m pip install --upgrade pip pipenv + pipenv sync -d + elif [[ -f requirements.txt ]]; then + python -m pip install --upgrade pip + pip install -r requirements.txt + elif [[ -f Makefile ]]; then + make install + else + echo "No manifest files found to install dependencies" + fi - name: Run tests run: | - ./${{ github.action_path }}/script/testing.sh "python" + set -e + if [[ -f pyproject.toml ]]; then + poetry run test + elif [[ -f Pipfile ]]; then + pipenv run test + elif [[ -f Makefile ]]; then + make test + else + pytest + fi From c674411200a2400e296f075a632b5b666cc5c4e6 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Fri, 16 Aug 2024 17:00:20 +0000 Subject: [PATCH 12/37] feat: Add general Python workflow --- .github/workflows/python.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/python.yml diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 0000000..a88627b --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,29 @@ +# Python Testing Workflow +# +# - Automatically runs tests on all supported versions of Python +name: Python + +on: + pull_request: + workflow_call: + inputs: + versions: + description: 'Python versions to test against' + type: string + # All Major versions of Python that are currently supported + default: '3.9,3.10,3.11,3.12' + + +jobs: + testing: + uses: advanced-security/reusable-workflows/.github/workflows/python-testing.yml@v0.1.0 + secrets: inherit + with: + versions: ${{ inputs.versions }} + + linting: + uses: advanced-security/reusable-workflows/.github/workflows/python-linting.yml@v0.1.0 + needs: [ testing ] + secrets: inherit + with: + versions: ${{ inputs.versions }} From 74ae7c20a7a530f3822f9651fe439df81a939ffc Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Fri, 16 Aug 2024 17:00:35 +0000 Subject: [PATCH 13/37] feat: Add Patch-Release-Me config --- .release.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .release.yml diff --git a/.release.yml b/.release.yml new file mode 100644 index 0000000..27c11aa --- /dev/null +++ b/.release.yml @@ -0,0 +1,10 @@ +name: "reusable-workflows" +version: "0.1.0" + +locations: + - name: "Actions Versions" + paths: + - '.github/workflows/*.yml' + patterns: + # Actions + - 'advanced-security/reusable-workflows/.github/workflows/.*\.yml@v([0-9]\.[0-9]\.[0-9])' From 9e2380db0aa3435b7f2b1b5e2d84f1441603a70f Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Fri, 16 Aug 2024 17:02:30 +0000 Subject: [PATCH 14/37] feat: Add better logging --- .github/workflows/python-testing.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/python-testing.yml b/.github/workflows/python-testing.yml index bcd11f4..5e4bb6a 100644 --- a/.github/workflows/python-testing.yml +++ b/.github/workflows/python-testing.yml @@ -50,6 +50,7 @@ jobs: - name: Install dependencies run: | set -e + echo "Installing dependencies..." if [[ -f pyproject.toml ]]; then python -m pip install --upgrade pip poetry poetry install @@ -68,12 +69,17 @@ jobs: - name: Run tests run: | set -e + echo "Running Python tests..." if [[ -f pyproject.toml ]]; then + echo "Running poetry run test" poetry run test elif [[ -f Pipfile ]]; then + echo "Running pipenv run test" pipenv run test elif [[ -f Makefile ]]; then + echo "Running make test" make test else + echo "Running pytest" pytest fi From 161d338ec99da2774a5d6e57a42d1da1f5643095 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Fri, 16 Aug 2024 17:07:07 +0000 Subject: [PATCH 15/37] feat: Add better testing support --- .github/workflows/python-testing.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-testing.yml b/.github/workflows/python-testing.yml index 5e4bb6a..bed0b48 100644 --- a/.github/workflows/python-testing.yml +++ b/.github/workflows/python-testing.yml @@ -80,6 +80,6 @@ jobs: echo "Running make test" make test else - echo "Running pytest" - pytest + echo "Unknown test runner..." + echo "Please contact the oss-maintainers team for help." fi From 47dba7ca7c32091d4cb15fd7d6c5abe7b0942d6b Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:09:45 +0000 Subject: [PATCH 16/37] feat: Add Python Vendor reusable workflow --- .github/workflows/python-vendor.yml | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/python-vendor.yml diff --git a/.github/workflows/python-vendor.yml b/.github/workflows/python-vendor.yml new file mode 100644 index 0000000..a93193c --- /dev/null +++ b/.github/workflows/python-vendor.yml @@ -0,0 +1,69 @@ +# Python Vendoring Workflow +name: Python - Vendoring + +on: + push: + pull_request: + workflow_call: + inputs: + custom-property: + description: 'Name of the custom property to get value from' + type: string + default: 'OSSType' + version: + description: 'Python main version to vendor' + type: string + # All Major versions of Python that are currently supported + default: '3.11' + +jobs: + custom-property: + runs-on: ubuntu-latest + outputs: + osstype: ${{ steps.get_custom_property.outputs.osstype }} + + steps: + - name: "Get Custom Property" + id: get_custom_property + run: | + set -e + PROPERTY_NAME="${{ inputs.custom-property }}" + + PROPERTIES=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/:owner/:repo/properties/values) + echo "Properties: '$PROPERTIES'" + + REPOSITORY_TYPE=$(echo $PROPERTIES | jq -r ".[] | select(.property_name == \"$PROPERTY_NAME\") | .value") + echo "Repository type: '$REPOSITORY_TYPE'" + echo "osstype=[$REPOSITORY_TYPE]" >> "$GITHUB_OUTPUT" + + python-vendoring: + runs-on: ubuntu-latest + if: ${{ needs.custom-property.outputs.osstype == 'Actions' }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python ${{ inputs.version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.version }} + + - name: "Install and Vendor dependencies" + run: | + set -e + + if [[ -f Pipfile ]]; then + python -m pip install --upgrade pip pipenv + pipenv run vendor + elif [[ -f vendor/update.sh ]]; then + ./vendor/update.sh + else + echo "Unknown vendoring method" + fi + + - name: "Verify vendored dependencies (PR)" + if: ${{ github.event_name == 'pull_request' }} + run: | + set -e + + git diff --exit-code From e94f1de61c7b6ebcd5d82258274359e421b691e7 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:14:42 +0000 Subject: [PATCH 17/37] fix: GitHub Token and Env vars --- .github/workflows/python-vendor.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-vendor.yml b/.github/workflows/python-vendor.yml index a93193c..e80e1ba 100644 --- a/.github/workflows/python-vendor.yml +++ b/.github/workflows/python-vendor.yml @@ -25,9 +25,11 @@ jobs: steps: - name: "Get Custom Property" id: get_custom_property + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PROPERTY_NAME: ${{ inputs.custom-property }} run: | set -e - PROPERTY_NAME="${{ inputs.custom-property }}" PROPERTIES=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/:owner/:repo/properties/values) echo "Properties: '$PROPERTIES'" From ba4a936f5c0d19b0fd5c486f9630a743b9fe90b0 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:16:24 +0000 Subject: [PATCH 18/37] fix: Custom Property --- .github/workflows/python-vendor.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-vendor.yml b/.github/workflows/python-vendor.yml index e80e1ba..85e960f 100644 --- a/.github/workflows/python-vendor.yml +++ b/.github/workflows/python-vendor.yml @@ -26,7 +26,7 @@ jobs: - name: "Get Custom Property" id: get_custom_property env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ github.token }} PROPERTY_NAME: ${{ inputs.custom-property }} run: | set -e @@ -40,6 +40,7 @@ jobs: python-vendoring: runs-on: ubuntu-latest + needs: [ custom-property ] if: ${{ needs.custom-property.outputs.osstype == 'Actions' }} steps: - name: Checkout From d03474ea82798373ca7b606590471acdb6bbcb06 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:16:58 +0000 Subject: [PATCH 19/37] fix: Add checkout --- .github/workflows/python-vendor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python-vendor.yml b/.github/workflows/python-vendor.yml index 85e960f..fd4be92 100644 --- a/.github/workflows/python-vendor.yml +++ b/.github/workflows/python-vendor.yml @@ -23,6 +23,8 @@ jobs: osstype: ${{ steps.get_custom_property.outputs.osstype }} steps: + - name: Checkout + uses: actions/checkout@v4 - name: "Get Custom Property" id: get_custom_property env: From a2e3b9e4f9c60fb505e61976519786e84f535fc4 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:19:04 +0000 Subject: [PATCH 20/37] fix: Output of the custom property --- .github/workflows/python-vendor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-vendor.yml b/.github/workflows/python-vendor.yml index fd4be92..abea6ee 100644 --- a/.github/workflows/python-vendor.yml +++ b/.github/workflows/python-vendor.yml @@ -38,7 +38,7 @@ jobs: REPOSITORY_TYPE=$(echo $PROPERTIES | jq -r ".[] | select(.property_name == \"$PROPERTY_NAME\") | .value") echo "Repository type: '$REPOSITORY_TYPE'" - echo "osstype=[$REPOSITORY_TYPE]" >> "$GITHUB_OUTPUT" + echo "osstype=$REPOSITORY_TYPE" >> "$GITHUB_OUTPUT" python-vendoring: runs-on: ubuntu-latest From 9375669ce71e56c7cc7e36cbe020df0f7412e440 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:34:16 +0000 Subject: [PATCH 21/37] feat: Add Update PR support --- .github/workflows/python-vendor.yml | 32 ++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/workflows/python-vendor.yml b/.github/workflows/python-vendor.yml index abea6ee..63ed7f5 100644 --- a/.github/workflows/python-vendor.yml +++ b/.github/workflows/python-vendor.yml @@ -60,15 +60,33 @@ jobs: if [[ -f Pipfile ]]; then python -m pip install --upgrade pip pipenv pipenv run vendor + elif [[ -f Makefile ]]; then + make vendor elif [[ -f vendor/update.sh ]]; then ./vendor/update.sh else echo "Unknown vendoring method" fi - - - name: "Verify vendored dependencies (PR)" - if: ${{ github.event_name == 'pull_request' }} - run: | - set -e - - git diff --exit-code + + - name: "Update vendored dependencies (Push)" + if: ${{ github.event_name == 'push' }} + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ github.token }} + commit-message: Verify vendored dependencies + title: Verify vendored dependencies + branch: verify-vendored-dependencies + base: ${{ github.event.before }} + labels: dependencies + delete-branch: true + body: | + This is an automated PR to update that vendored dependencies are up to date. + It was created by a GitHub workflow defined in `.github/workflows/python-vendor.yml`. + Please do not merge this PR manually. +
+ Details +

+ This PR was created by a workflow that runs on all pushes to the repository. + It installs dependencies and then verifies that the repository is clean. +

+
From 46c710021b3d90d29b332faf8c103b787c05a06d Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:39:53 +0000 Subject: [PATCH 22/37] feat: Add permissions and update PR creation --- .github/workflows/python-vendor.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-vendor.yml b/.github/workflows/python-vendor.yml index 63ed7f5..85e2e96 100644 --- a/.github/workflows/python-vendor.yml +++ b/.github/workflows/python-vendor.yml @@ -16,6 +16,11 @@ on: # All Major versions of Python that are currently supported default: '3.11' +permissions: + properties: read + contents: write + pull-requests: write + jobs: custom-property: runs-on: ubuntu-latest @@ -69,16 +74,15 @@ jobs: fi - name: "Update vendored dependencies (Push)" - if: ${{ github.event_name == 'push' }} + if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} uses: peter-evans/create-pull-request@v6 with: token: ${{ github.token }} - commit-message: Verify vendored dependencies - title: Verify vendored dependencies - branch: verify-vendored-dependencies + commit-message: "[chore]: Update vendored dependencies" + title: "[chore]: Update vendored dependencies" + branch: update-vendored-dependencies base: ${{ github.event.before }} labels: dependencies - delete-branch: true body: | This is an automated PR to update that vendored dependencies are up to date. It was created by a GitHub workflow defined in `.github/workflows/python-vendor.yml`. From 7c3bece38082e560c708edb8b2524c607d51ed5a Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:43:44 +0000 Subject: [PATCH 23/37] fix: Permissions --- .github/workflows/python-vendor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/python-vendor.yml b/.github/workflows/python-vendor.yml index 85e2e96..c4f28d5 100644 --- a/.github/workflows/python-vendor.yml +++ b/.github/workflows/python-vendor.yml @@ -17,7 +17,6 @@ on: default: '3.11' permissions: - properties: read contents: write pull-requests: write From f91b7ab78b9a56a737685fc8fd0c3827c47ec4f7 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:49:58 +0000 Subject: [PATCH 24/37] feat: Add change detection support --- .github/workflows/python-vendor.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-vendor.yml b/.github/workflows/python-vendor.yml index c4f28d5..c7267d0 100644 --- a/.github/workflows/python-vendor.yml +++ b/.github/workflows/python-vendor.yml @@ -58,6 +58,7 @@ jobs: python-version: ${{ inputs.version }} - name: "Install and Vendor dependencies" + id: vendoring run: | set -e @@ -71,9 +72,12 @@ jobs: else echo "Unknown vendoring method" fi + + CHANGES=$(git status --porcelain | wc -l) + echo "changes=$CHANGES" >> "$GITHUB_OUTPUT" - name: "Update vendored dependencies (Push)" - if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} + if: ${{ steps.vendoring.outputs.changes != 0 && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }} uses: peter-evans/create-pull-request@v6 with: token: ${{ github.token }} From 32b441aec7e654bc5a134bd44dc18c16aa2866c3 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:50:31 +0000 Subject: [PATCH 25/37] feat: Update Python workflow to support vendoring --- .github/workflows/python.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index a88627b..7d5b861 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -7,23 +7,44 @@ on: pull_request: workflow_call: inputs: + version: + description: 'Python main version to vendor' + type: string + # All Major versions of Python that are currently supported + default: '3.11' versions: description: 'Python versions to test against' type: string # All Major versions of Python that are currently supported default: '3.9,3.10,3.11,3.12' + vendor: + description: 'Whether to vendor the dependencies' + type: string + default: 'true' jobs: + # Run the tests on all supported versions of Python testing: uses: advanced-security/reusable-workflows/.github/workflows/python-testing.yml@v0.1.0 secrets: inherit with: versions: ${{ inputs.versions }} + # Run linters on the codebase linting: uses: advanced-security/reusable-workflows/.github/workflows/python-linting.yml@v0.1.0 needs: [ testing ] secrets: inherit with: versions: ${{ inputs.versions }} + + # Vendor the dependencies into the repository if needed + vendoring: + uses: advanced-security/reusable-workflows/.github/workflows/python-vendor.yml@v0.1.0 + needs: [ testing, linting ] + if: ${{ inputs.vendor == 'true' }} + secrets: inherit + with: + version: ${{ inputs.version }} + custom-property: 'OSSType' From 99ab1199db16e46b0e6e9108ae7bea8cc4fd78b0 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 12:40:31 +0000 Subject: [PATCH 26/37] feat: Python Release workflow --- .github/workflows/python-release.yml | 69 ++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/python-release.yml diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml new file mode 100644 index 0000000..1bc7bf0 --- /dev/null +++ b/.github/workflows/python-release.yml @@ -0,0 +1,69 @@ +# Python Releasing Workflow +name: Python - Release + +on: + push: + workflow_call: + inputs: + version: + description: 'Python main version to vendor' + type: string + # All Major versions of Python that are currently supported + default: '3.11' + +permissions: + contents: write + pull-requests: write + +jobs: + version-changes: + runs-on: ubuntu-latest + outputs: + release: ${{ steps.check_release.outputs.release }} + version: ${{ steps.check_release.outputs.current_version }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: "Check release" + id: check_release + run: | + set -e + + if [[ -f .release.yml ]]; then + pip install yq + current_version=$(cat .release.yml | yq -r ".version") + elif [[ -f pyproject.toml ]]; then + current_version=$(grep -oP '^version = "(.*)"$' pyproject.toml | cut -d '"' -f 2) + elif [[ -f setup.py ]]; then + current_version=$(grep -oP '^__version__ = "(.*)"$' setup.py | cut -d '"' -f 2) + else + echo "No version file found" + current_version="NA" + fi + + released_version=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/:owner/:repo/releases/latest | jq -r ".tag_name") + + if [[ "$current_version" == "NA" || "$current_version" == "$released_version" ]]; then + echo "No new release found" + echo "release=false" >> "$GITHUB_OUTPUT" + else + echo "New release found" + echo "version=$current_version" >> "$GITHUB_OUTPUT" + echo "release=true" >> "$GITHUB_OUTPUT" + fi + + python-release: + runs-on: ubuntu-latest + needs: [ version-changes ] + if: + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python ${{ inputs.version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.version }} + \ No newline at end of file From 5a87e2744edb9626f2751991f6259e743eed780a Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 12:46:06 +0000 Subject: [PATCH 27/37] feat: Add GitHub Releases --- .github/workflows/python-release.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml index 1bc7bf0..e0f00ff 100644 --- a/.github/workflows/python-release.yml +++ b/.github/workflows/python-release.yml @@ -57,7 +57,7 @@ jobs: python-release: runs-on: ubuntu-latest needs: [ version-changes ] - if: + if: ${{ needs.version-changes.outputs.release == 'true' }} steps: - name: Checkout uses: actions/checkout@v4 @@ -66,4 +66,19 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ inputs.version }} + + - name: "GitHub Release" + env: + GH_TOKEN: ${{ github.token }} + run: | + git config user.name github-actions + git config user.email github-actions@github.com + + git tag "${{ needs.version-changes.outputs.version }}" --force + git push origin ${{ github.ref_name }} + git push origin --tags --force + + gh release create --latest --generate-notes \ + --title "v${{ needs.version-changes.outputs.version }}" \ + "${{ needs.version-changes.outputs.version }}" \ No newline at end of file From b61ce07a50db7330a01aea718c2fc62190e140b0 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 12:47:57 +0000 Subject: [PATCH 28/37] fix: Add GH Token --- .github/workflows/python-release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml index e0f00ff..0b50f5f 100644 --- a/.github/workflows/python-release.yml +++ b/.github/workflows/python-release.yml @@ -28,6 +28,8 @@ jobs: - name: "Check release" id: check_release + env: + GH_TOKEN: ${{ github.token }} run: | set -e From cbe259108fc5f5a7d401434a69d870ee3b76d9c4 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 12:51:36 +0000 Subject: [PATCH 29/37] fix: Update version output --- .github/workflows/python-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml index 0b50f5f..fd2c3aa 100644 --- a/.github/workflows/python-release.yml +++ b/.github/workflows/python-release.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest outputs: release: ${{ steps.check_release.outputs.release }} - version: ${{ steps.check_release.outputs.current_version }} + version: ${{ steps.check_release.outputs.version }} steps: - name: Checkout From 6801d56b1ed84a1171959e9fc6b5da72c160911f Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 15:52:54 +0000 Subject: [PATCH 30/37] feat: Add GitHub Release --- .github/workflows/release.yml | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..eb93167 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +# GitHub Releasing Workflow +name: GitHub - Release + +on: + push: + workflow_call: + inputs: + version: + description: "The version to release" + required: true + type: string + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + # https://github.com/peter-murray/semver-data-action + - name: Parse SemVer + id: version + uses: peter-murray/semver-action@v1 + with: + version: ${{ inputs.version }} + + # Tags :: ${Full}, v${Major}, v${Major}.${Minor}, v${Major}.${Minor}.${Patch} + - name: "GitHub Release" + env: + GH_TOKEN: ${{ github.token }} + run: | + git config user.name github-actions + git config user.email github-actions@github.com + + git tag "${{ steps.version.outputs.version }}" --force + git tag "v${{ steps.version.outputs.major }}" --force + git tag "v${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}" --force + git tag "v${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}" --force + + git push origin ${{ github.ref_name }} + git push origin --tags --force + + gh release create --latest --generate-notes \ + --title "v${{ needs.version-changes.outputs.version }}" \ + "${{ needs.version-changes.outputs.version }}" + \ No newline at end of file From d1a5bc11dbdd281de4c6a7b779308a55b0a1125f Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 15:55:05 +0000 Subject: [PATCH 31/37] feat: Replace Python release with GitHub release --- .github/workflows/python-release.yml | 32 +++++----------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml index fd2c3aa..cff8863 100644 --- a/.github/workflows/python-release.yml +++ b/.github/workflows/python-release.yml @@ -56,31 +56,9 @@ jobs: echo "release=true" >> "$GITHUB_OUTPUT" fi - python-release: - runs-on: ubuntu-latest + github-release: + uses: advanced-security/reusable-workflows/.github/workflows/release.yml@v0.1.0 needs: [ version-changes ] - if: ${{ needs.version-changes.outputs.release == 'true' }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Python ${{ inputs.version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ inputs.version }} - - - name: "GitHub Release" - env: - GH_TOKEN: ${{ github.token }} - run: | - git config user.name github-actions - git config user.email github-actions@github.com - - git tag "${{ needs.version-changes.outputs.version }}" --force - git push origin ${{ github.ref_name }} - git push origin --tags --force - - gh release create --latest --generate-notes \ - --title "v${{ needs.version-changes.outputs.version }}" \ - "${{ needs.version-changes.outputs.version }}" - \ No newline at end of file + secrets: inherit + with: + version: ${{ needs.version-changes.outputs.version }} From b4e19b31d4d4d86a73fbebec909d9102dbbe4fb0 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 16:00:28 +0000 Subject: [PATCH 32/37] fix: Add check --- .github/workflows/python-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml index cff8863..d565dd4 100644 --- a/.github/workflows/python-release.yml +++ b/.github/workflows/python-release.yml @@ -59,6 +59,7 @@ jobs: github-release: uses: advanced-security/reusable-workflows/.github/workflows/release.yml@v0.1.0 needs: [ version-changes ] + if: ${{ needs.version-changes.outputs.release == 'true' }} secrets: inherit with: version: ${{ needs.version-changes.outputs.version }} From c7e3eb4cf05b10150131580ec5069333fe9e1e18 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Tue, 20 Aug 2024 16:02:30 +0000 Subject: [PATCH 33/37] feat: Add release to Python workflow --- .github/workflows/python.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 7d5b861..c130890 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -48,3 +48,11 @@ jobs: with: version: ${{ inputs.version }} custom-property: 'OSSType' + + # Release a new version of the package + release: + uses: advanced-security/reusable-workflows/.github/workflows/python-release.yml@v0.1.0 + needs: [ testing, linting ] + secrets: inherit + with: + version: ${{ inputs.version }} From bcae62d193e22997ae370bff7ab0a3761b2f9a5c Mon Sep 17 00:00:00 2001 From: Mathew Payne Date: Mon, 2 Sep 2024 10:56:09 +0100 Subject: [PATCH 34/37] feat: Remove release --- .github/workflows/release.yml | 46 ----------------------------------- .release.yml | 10 -------- 2 files changed, 56 deletions(-) delete mode 100644 .github/workflows/release.yml delete mode 100644 .release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index eb93167..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,46 +0,0 @@ -# GitHub Releasing Workflow -name: GitHub - Release - -on: - push: - workflow_call: - inputs: - version: - description: "The version to release" - required: true - type: string - -permissions: - contents: write - -jobs: - release: - runs-on: ubuntu-latest - steps: - # https://github.com/peter-murray/semver-data-action - - name: Parse SemVer - id: version - uses: peter-murray/semver-action@v1 - with: - version: ${{ inputs.version }} - - # Tags :: ${Full}, v${Major}, v${Major}.${Minor}, v${Major}.${Minor}.${Patch} - - name: "GitHub Release" - env: - GH_TOKEN: ${{ github.token }} - run: | - git config user.name github-actions - git config user.email github-actions@github.com - - git tag "${{ steps.version.outputs.version }}" --force - git tag "v${{ steps.version.outputs.major }}" --force - git tag "v${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}" --force - git tag "v${{ steps.version.outputs.major }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}" --force - - git push origin ${{ github.ref_name }} - git push origin --tags --force - - gh release create --latest --generate-notes \ - --title "v${{ needs.version-changes.outputs.version }}" \ - "${{ needs.version-changes.outputs.version }}" - \ No newline at end of file diff --git a/.release.yml b/.release.yml deleted file mode 100644 index 27c11aa..0000000 --- a/.release.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: "reusable-workflows" -version: "0.1.0" - -locations: - - name: "Actions Versions" - paths: - - '.github/workflows/*.yml' - patterns: - # Actions - - 'advanced-security/reusable-workflows/.github/workflows/.*\.yml@v([0-9]\.[0-9]\.[0-9])' From 2c52d08076846bea4b7281f7309812d268f32c64 Mon Sep 17 00:00:00 2001 From: Mathew Payne Date: Mon, 2 Sep 2024 10:57:19 +0100 Subject: [PATCH 35/37] feat: Remove scripts --- scripts/install.sh | 23 ----------------------- scripts/linting.sh | 19 ------------------- scripts/testing.sh | 18 ------------------ 3 files changed, 60 deletions(-) delete mode 100755 scripts/install.sh delete mode 100755 scripts/linting.sh delete mode 100755 scripts/testing.sh diff --git a/scripts/install.sh b/scripts/install.sh deleted file mode 100755 index f53ae9d..0000000 --- a/scripts/install.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -e - -LANGUAGE=${LANGUAGE:-"python"} - -if [[ "$LANGUAGE" == "python" ]]; then - echo "Installing Python dependencies..." - - if [[ -f pyproject.toml ]]; then - python -m pip install --upgrade pip poetry - poetry install - elif [[ -f Pipfile ]]; then - python -m pip install --upgrade pip pipenv - pipenv sync -d - elif [[ -f requirements.txt ]]; then - python -m pip install --upgrade pip - pip install -r requirements.txt - elif [[ -f Makefile ]]; then - make install - else - echo "No manifest files found to install dependencies" - fi -fi \ No newline at end of file diff --git a/scripts/linting.sh b/scripts/linting.sh deleted file mode 100755 index a121884..0000000 --- a/scripts/linting.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -LANGUAGE=${1:-"python"} -TOOL=${2:-"ruff"} - -if [[ "$LANGUAGE" == "python" ]]; then - echo "Linting Python..." - - if [[ "$TOOL" == "ruff" ]]; then - pip install ruff - ruff check - elif [[ "$TOOL" == "flake8" ]]; then - pip install flake8 - flake8 . - elif [[ "$TOOL" == "black" ]]; then - pip install black - black --check . - fi -fi diff --git a/scripts/testing.sh b/scripts/testing.sh deleted file mode 100755 index 73fe305..0000000 --- a/scripts/testing.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -set -e - -LANGUAGE=${LANGUAGE:-"python"} - -if [[ "$LANGUAGE" == "python" ]]; then - echo "Testing Python dependencies..." - - if [[ -f pyproject.toml ]]; then - poetry run test - elif [[ -f Pipfile ]]; then - pipenv run test - elif [[ -f Makefile ]]; then - make test - else - pytest - fi -fi \ No newline at end of file From b76c822d3af92a8ca448139af48a1fc5e4ecb380 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:02:19 +0000 Subject: [PATCH 36/37] fix: Update typo --- .github/workflows/python-linting.yml | 8 ++++---- .github/workflows/python-testing.yml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python-linting.yml b/.github/workflows/python-linting.yml index c56fcce..0c4fdf0 100644 --- a/.github/workflows/python-linting.yml +++ b/.github/workflows/python-linting.yml @@ -18,7 +18,7 @@ on: default: '3.9,3.10,3.11,3.12' jobs: - python-verions: + python-versions: runs-on: ubuntu-latest outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} @@ -34,12 +34,12 @@ jobs: python-linting: runs-on: ubuntu-latest - if: ${{ needs.python-verions.outputs.matrix != '[]' }} - needs: [ python-verions ] + if: ${{ needs.python-versions.outputs.matrix != '[]' }} + needs: [ python-versions ] strategy: fail-fast: false matrix: - python-version: ${{ fromJson(needs.python-verions.outputs.matrix) }} + python-version: ${{ fromJson(needs.python-versions.outputs.matrix) }} steps: - name: Checkout diff --git a/.github/workflows/python-testing.yml b/.github/workflows/python-testing.yml index bed0b48..585c427 100644 --- a/.github/workflows/python-testing.yml +++ b/.github/workflows/python-testing.yml @@ -14,7 +14,7 @@ on: default: '3.9,3.10,3.11,3.12' jobs: - python-verions: + python-versions: runs-on: ubuntu-latest outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} @@ -31,12 +31,12 @@ jobs: python-testing: # This workflow runs on the latest version of Ubuntu runs-on: ubuntu-latest - if: ${{ needs.python-verions.outputs.matrix != '[]' }} - needs: [ python-verions ] + if: ${{ needs.python-versions.outputs.matrix != '[]' }} + needs: [ python-versions ] strategy: fail-fast: false matrix: - python-version: ${{ fromJSON(needs.python-verions.outputs.matrix) }} + python-version: ${{ fromJSON(needs.python-versions.outputs.matrix) }} steps: - name: Checkout From d9ccea8737f7ed86d8c6b8e3ff03c783270edb63 Mon Sep 17 00:00:00 2001 From: Mathew Payne <2772944+GeekMasher@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:03:26 +0000 Subject: [PATCH 37/37] fix: Update to main for now --- .github/workflows/python-release.yml | 2 +- .github/workflows/python.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml index d565dd4..ccbc234 100644 --- a/.github/workflows/python-release.yml +++ b/.github/workflows/python-release.yml @@ -57,7 +57,7 @@ jobs: fi github-release: - uses: advanced-security/reusable-workflows/.github/workflows/release.yml@v0.1.0 + uses: advanced-security/reusable-workflows/.github/workflows/release.yml@main needs: [ version-changes ] if: ${{ needs.version-changes.outputs.release == 'true' }} secrets: inherit diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index c130890..b9b7602 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -26,14 +26,14 @@ on: jobs: # Run the tests on all supported versions of Python testing: - uses: advanced-security/reusable-workflows/.github/workflows/python-testing.yml@v0.1.0 + uses: advanced-security/reusable-workflows/.github/workflows/python-testing.yml@main secrets: inherit with: versions: ${{ inputs.versions }} # Run linters on the codebase linting: - uses: advanced-security/reusable-workflows/.github/workflows/python-linting.yml@v0.1.0 + uses: advanced-security/reusable-workflows/.github/workflows/python-linting.yml@main needs: [ testing ] secrets: inherit with: @@ -41,7 +41,7 @@ jobs: # Vendor the dependencies into the repository if needed vendoring: - uses: advanced-security/reusable-workflows/.github/workflows/python-vendor.yml@v0.1.0 + uses: advanced-security/reusable-workflows/.github/workflows/python-vendor.yml@main needs: [ testing, linting ] if: ${{ inputs.vendor == 'true' }} secrets: inherit @@ -51,7 +51,7 @@ jobs: # Release a new version of the package release: - uses: advanced-security/reusable-workflows/.github/workflows/python-release.yml@v0.1.0 + uses: advanced-security/reusable-workflows/.github/workflows/python-release.yml@main needs: [ testing, linting ] secrets: inherit with: