From 15c898c3e72ece992d05bc65b291a2333b42ef6c Mon Sep 17 00:00:00 2001 From: Rik Bouwmeester Date: Fri, 25 Oct 2024 13:01:18 +0200 Subject: [PATCH 01/10] Add build workflow using native GitHub Actions --- .github/workflows/build.yml | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..7edf0d40a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,46 @@ +name: Build + +on: + workflow_call: + workflow_dispatch: + +jobs: + build: + runs-on: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: | + 3.10 + 3.11 + 3.12 + 3.13 + - run: pip install build + - run: python -m build + pip-install: + runs-on: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: | + 3.10 + 3.11 + 3.12 + 3.13 + - run: pip install build + - run: pip install . + pip-editable-install: + runs-on: [ubuntu-latest, windows-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: | + 3.10 + 3.11 + 3.12 + 3.13 + - run: pip install build + - run: pip install -e . From 3194cfa522df5b77822ae5a88bcd881373c03fd9 Mon Sep 17 00:00:00 2001 From: Rik Bouwmeester Date: Fri, 25 Oct 2024 13:09:07 +0200 Subject: [PATCH 02/10] Add a PR trigger to new build workflow to do an initial trigger of the workflow --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7edf0d40a..a5b677995 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,6 +3,7 @@ name: Build on: workflow_call: workflow_dispatch: + pull_request: # to register the in-branch workflow jobs: build: From 043a58dbd97bdfa52f763291dc1268dec7b6e1fe Mon Sep 17 00:00:00 2001 From: Rik Bouwmeester Date: Fri, 25 Oct 2024 13:14:17 +0200 Subject: [PATCH 03/10] Only test build on ubuntu-latest --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a5b677995..0cdddf5f9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ on: jobs: build: - runs-on: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -20,7 +20,7 @@ jobs: - run: pip install build - run: python -m build pip-install: - runs-on: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -33,7 +33,7 @@ jobs: - run: pip install build - run: pip install . pip-editable-install: - runs-on: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 From 70cacdc7128c5b766e13aeaa1936a6e24504a3c9 Mon Sep 17 00:00:00 2001 From: Rik Bouwmeester Date: Fri, 25 Oct 2024 13:19:34 +0200 Subject: [PATCH 04/10] Revert "Only test build on ubuntu-latest" This reverts commit 043a58dbd97bdfa52f763291dc1268dec7b6e1fe. --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0cdddf5f9..a5b677995 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -20,7 +20,7 @@ jobs: - run: pip install build - run: python -m build pip-install: - runs-on: ubuntu-latest + runs-on: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -33,7 +33,7 @@ jobs: - run: pip install build - run: pip install . pip-editable-install: - runs-on: ubuntu-latest + runs-on: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 From 7fd47fcef7e7ed56a5cc415f935cf9119bc160f8 Mon Sep 17 00:00:00 2001 From: Rik Bouwmeester Date: Fri, 25 Oct 2024 13:40:58 +0200 Subject: [PATCH 05/10] Build on all supported Python versions --- .github/workflows/build.yml | 41 +++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a5b677995..e88f2cf46 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,42 +6,53 @@ on: pull_request: # to register the in-branch workflow jobs: + define-matrix: + runs-on: ubuntu-latest + + outputs: + python-version: ${{ steps.python-version.outputs.python-version }} + steps: + - name: Define supported Python versions + id: python-version + run: | + echo 'python-version=["3.10", "3.11", "3.12", "3.13"]' >> "$GITHUB_OUTPUT" + build: + needs: define-matrix runs-on: [ubuntu-latest, windows-latest, macos-latest] + strategy: + matrix: + python-version: ${{ fromJSON(needs.define-matrix.outputs.python-version) }} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: | - 3.10 - 3.11 - 3.12 - 3.13 + python-version: ${{ matrix.python-version }} - run: pip install build - run: python -m build pip-install: + needs: define-matrix runs-on: [ubuntu-latest, windows-latest, macos-latest] + strategy: + matrix: + python-version: ${{ fromJSON(needs.define-matrix.outputs.python-version) }} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: | - 3.10 - 3.11 - 3.12 - 3.13 + python-version: ${{ matrix.python-version }} - run: pip install build - run: pip install . pip-editable-install: + needs: define-matrix runs-on: [ubuntu-latest, windows-latest, macos-latest] + strategy: + matrix: + python-version: ${{ fromJSON(needs.define-matrix.outputs.python-version) }} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: | - 3.10 - 3.11 - 3.12 - 3.13 + python-version: ${{ matrix.python-version }} - run: pip install build - run: pip install -e . From 7fea8396a0f3369a154674dedf6231f973b00295 Mon Sep 17 00:00:00 2001 From: Rik Bouwmeester Date: Fri, 25 Oct 2024 13:44:14 +0200 Subject: [PATCH 06/10] No build testing on macOS, Windows --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e88f2cf46..3011eadc1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: build: needs: define-matrix - runs-on: [ubuntu-latest, windows-latest, macos-latest] + runs-on: [ubuntu-latest] strategy: matrix: python-version: ${{ fromJSON(needs.define-matrix.outputs.python-version) }} @@ -32,7 +32,7 @@ jobs: - run: python -m build pip-install: needs: define-matrix - runs-on: [ubuntu-latest, windows-latest, macos-latest] + runs-on: [ubuntu-latest] strategy: matrix: python-version: ${{ fromJSON(needs.define-matrix.outputs.python-version) }} @@ -45,7 +45,7 @@ jobs: - run: pip install . pip-editable-install: needs: define-matrix - runs-on: [ubuntu-latest, windows-latest, macos-latest] + runs-on: [ubuntu-latest] strategy: matrix: python-version: ${{ fromJSON(needs.define-matrix.outputs.python-version) }} From c06ea3b860fbe9ebda76ab2426c9a13f3f62d891 Mon Sep 17 00:00:00 2001 From: Rik Bouwmeester Date: Fri, 25 Oct 2024 15:02:15 +0200 Subject: [PATCH 07/10] Test only oldest and newest supported Python Add formatting (pre-commit) test Run unit tests Test build docs, do basic pip install to fetch dependencies --- .github/workflows/build.yml | 55 +++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3011eadc1..47d30df7f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,7 +6,29 @@ on: pull_request: # to register the in-branch workflow jobs: - define-matrix: + verify: + name: Check code formatting and run tests + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: Install pre-commit + run: pip install pre-commit + - name: Check code formatting + run: pre-commit run --all-files + - name: Basic install to fetch dependencies for tests + run: pip install . + - name: Install test dependencies + run: pip install pytest setuptools + - name: Run tests + run : python3 -m unittest discover test + + define-python-version-matrix: + needs: verify runs-on: ubuntu-latest outputs: @@ -15,14 +37,14 @@ jobs: - name: Define supported Python versions id: python-version run: | - echo 'python-version=["3.10", "3.11", "3.12", "3.13"]' >> "$GITHUB_OUTPUT" + echo 'python-version=["3.10", "3.13"]' >> "$GITHUB_OUTPUT" build: - needs: define-matrix + needs: define-python-version-matrix runs-on: [ubuntu-latest] strategy: matrix: - python-version: ${{ fromJSON(needs.define-matrix.outputs.python-version) }} + python-version: ${{ fromJSON(needs.define-python-version-matrix.outputs.python-version) }} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -30,12 +52,13 @@ jobs: python-version: ${{ matrix.python-version }} - run: pip install build - run: python -m build + pip-install: - needs: define-matrix + needs: define-python-version-matrix runs-on: [ubuntu-latest] strategy: matrix: - python-version: ${{ fromJSON(needs.define-matrix.outputs.python-version) }} + python-version: ${{ fromJSON(needs.define-python-version-matrix.outputs.python-version) }} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -43,12 +66,13 @@ jobs: python-version: ${{ matrix.python-version }} - run: pip install build - run: pip install . + pip-editable-install: - needs: define-matrix + needs: define-python-version-matrix runs-on: [ubuntu-latest] strategy: matrix: - python-version: ${{ fromJSON(needs.define-matrix.outputs.python-version) }} + python-version: ${{ fromJSON(needs.define-python-version-matrix.outputs.python-version) }} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -56,3 +80,18 @@ jobs: python-version: ${{ matrix.python-version }} - run: pip install build - run: pip install -e . + + build-docs: + needs: verify + runs-on: [ubuntu-latest] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: install cflib + run: pip install . + - name: install pdoc3 + run: pip install pdoc3 + - name: build docs + run: pdoc3 docs/api/template From ee7a471ff8d02eb41f007c574ad90a36dae6ea0a Mon Sep 17 00:00:00 2001 From: Rik Bouwmeester Date: Fri, 25 Oct 2024 15:25:15 +0200 Subject: [PATCH 08/10] Name jobs, test all supported Python versions, run on push, pr and schedule --- .github/workflows/build.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 47d30df7f..9b0df1e90 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,12 @@ name: Build on: workflow_call: workflow_dispatch: - pull_request: # to register the in-branch workflow + push: + branches: [master] + pull_request: + branches: [master] + schedule: + - cron: '30 16 * * 6' jobs: verify: @@ -28,6 +33,7 @@ jobs: run : python3 -m unittest discover test define-python-version-matrix: + name: Define Python versions matrix needs: verify runs-on: ubuntu-latest @@ -37,9 +43,10 @@ jobs: - name: Define supported Python versions id: python-version run: | - echo 'python-version=["3.10", "3.13"]' >> "$GITHUB_OUTPUT" + echo 'python-version=["3.10", "3.11", "3.12", "3.13"]' >> "$GITHUB_OUTPUT" build: + name: Build package needs: define-python-version-matrix runs-on: [ubuntu-latest] strategy: @@ -54,6 +61,7 @@ jobs: - run: python -m build pip-install: + name: Install package with pip needs: define-python-version-matrix runs-on: [ubuntu-latest] strategy: @@ -68,6 +76,7 @@ jobs: - run: pip install . pip-editable-install: + name: Install package in editable mode with pip needs: define-python-version-matrix runs-on: [ubuntu-latest] strategy: @@ -82,6 +91,7 @@ jobs: - run: pip install -e . build-docs: + name: Build documentation needs: verify runs-on: [ubuntu-latest] steps: From d81a761dba3dcd927f4a40f6ceb0c46181639c29 Mon Sep 17 00:00:00 2001 From: Rik Bouwmeester Date: Fri, 25 Oct 2024 15:27:45 +0200 Subject: [PATCH 09/10] Replace existing CI with new GitHub actions native CI --- .github/workflows/CI.yml | 104 +++++++++++++++++++++++++++++++---- .github/workflows/build.yml | 107 ------------------------------------ 2 files changed, 93 insertions(+), 118 deletions(-) delete mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5204c1992..03bb87b4f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,25 +1,107 @@ -# Run check and build of the lib using the Bitcraze builder docker image name: CI on: + workflow_call: + workflow_dispatch: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] schedule: - # Weekly build to make sure dependencies are OK - cron: '30 16 * * 6' jobs: - build: + verify: + name: Check code formatting and run tests runs-on: ubuntu-latest - steps: - - name: Checkout repo + - name: Checkout code uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: Install pre-commit + run: pip install pre-commit + - name: Check code formatting + run: pre-commit run --all-files + - name: Basic install to fetch dependencies for tests + run: pip install . + - name: Install test dependencies + run: pip install pytest setuptools + - name: Run tests + run : python3 -m unittest discover test - - name: Build - run: docker run --rm -v ${PWD}:/module bitcraze/builder ./tools/build/build + define-python-version-matrix: + name: Define Python versions matrix + needs: verify + runs-on: ubuntu-latest - - name: Build docs - run: docker run --rm -v ${PWD}:/module bitcraze/web-builder ./tools/build-docs/build-docs + outputs: + python-version: ${{ steps.python-version.outputs.python-version }} + steps: + - name: Define supported Python versions + id: python-version + run: | + echo 'python-version=["3.10", "3.11", "3.12", "3.13"]' >> "$GITHUB_OUTPUT" + + build: + name: Build package + needs: define-python-version-matrix + runs-on: [ubuntu-latest] + strategy: + matrix: + python-version: ${{ fromJSON(needs.define-python-version-matrix.outputs.python-version) }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - run: pip install build + - run: python -m build + + pip-install: + name: Install package with pip + needs: define-python-version-matrix + runs-on: [ubuntu-latest] + strategy: + matrix: + python-version: ${{ fromJSON(needs.define-python-version-matrix.outputs.python-version) }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - run: pip install build + - run: pip install . + + pip-editable-install: + name: Install package in editable mode with pip + needs: define-python-version-matrix + runs-on: [ubuntu-latest] + strategy: + matrix: + python-version: ${{ fromJSON(needs.define-python-version-matrix.outputs.python-version) }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - run: pip install build + - run: pip install -e . + + build-docs: + name: Build documentation + needs: verify + runs-on: [ubuntu-latest] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - name: install cflib + run: pip install . + - name: install pdoc3 + run: pip install pdoc3 + - name: build docs + run: pdoc3 docs/api/template diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 9b0df1e90..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,107 +0,0 @@ -name: Build - -on: - workflow_call: - workflow_dispatch: - push: - branches: [master] - pull_request: - branches: [master] - schedule: - - cron: '30 16 * * 6' - -jobs: - verify: - name: Check code formatting and run tests - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.x - - name: Install pre-commit - run: pip install pre-commit - - name: Check code formatting - run: pre-commit run --all-files - - name: Basic install to fetch dependencies for tests - run: pip install . - - name: Install test dependencies - run: pip install pytest setuptools - - name: Run tests - run : python3 -m unittest discover test - - define-python-version-matrix: - name: Define Python versions matrix - needs: verify - runs-on: ubuntu-latest - - outputs: - python-version: ${{ steps.python-version.outputs.python-version }} - steps: - - name: Define supported Python versions - id: python-version - run: | - echo 'python-version=["3.10", "3.11", "3.12", "3.13"]' >> "$GITHUB_OUTPUT" - - build: - name: Build package - needs: define-python-version-matrix - runs-on: [ubuntu-latest] - strategy: - matrix: - python-version: ${{ fromJSON(needs.define-python-version-matrix.outputs.python-version) }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - run: pip install build - - run: python -m build - - pip-install: - name: Install package with pip - needs: define-python-version-matrix - runs-on: [ubuntu-latest] - strategy: - matrix: - python-version: ${{ fromJSON(needs.define-python-version-matrix.outputs.python-version) }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - run: pip install build - - run: pip install . - - pip-editable-install: - name: Install package in editable mode with pip - needs: define-python-version-matrix - runs-on: [ubuntu-latest] - strategy: - matrix: - python-version: ${{ fromJSON(needs.define-python-version-matrix.outputs.python-version) }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - run: pip install build - - run: pip install -e . - - build-docs: - name: Build documentation - needs: verify - runs-on: [ubuntu-latest] - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.x - - name: install cflib - run: pip install . - - name: install pdoc3 - run: pip install pdoc3 - - name: build docs - run: pdoc3 docs/api/template From b70191b5449b3472f2eedcc91a00b47ab950e622 Mon Sep 17 00:00:00 2001 From: Rik Bouwmeester Date: Fri, 25 Oct 2024 16:10:05 +0200 Subject: [PATCH 10/10] Remove largely redundant pip install tests to optimize CI workflow and reduce resource usage --- .github/workflows/CI.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 03bb87b4f..238541253 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -60,36 +60,6 @@ jobs: - run: pip install build - run: python -m build - pip-install: - name: Install package with pip - needs: define-python-version-matrix - runs-on: [ubuntu-latest] - strategy: - matrix: - python-version: ${{ fromJSON(needs.define-python-version-matrix.outputs.python-version) }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - run: pip install build - - run: pip install . - - pip-editable-install: - name: Install package in editable mode with pip - needs: define-python-version-matrix - runs-on: [ubuntu-latest] - strategy: - matrix: - python-version: ${{ fromJSON(needs.define-python-version-matrix.outputs.python-version) }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - run: pip install build - - run: pip install -e . - build-docs: name: Build documentation needs: verify