From 243a316802183cc1ca42353490c2d24a2b94da6a Mon Sep 17 00:00:00 2001 From: Zhi Ming Xu Date: Sun, 13 Jul 2025 04:15:48 -0400 Subject: [PATCH 1/6] ci: add tests-on-pr workflow file that doesn't upload to codecov --- .github/workflows/_tests-on-pr-no-codecov.yml | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/_tests-on-pr-no-codecov.yml diff --git a/.github/workflows/_tests-on-pr-no-codecov.yml b/.github/workflows/_tests-on-pr-no-codecov.yml new file mode 100644 index 0000000..f928e87 --- /dev/null +++ b/.github/workflows/_tests-on-pr-no-codecov.yml @@ -0,0 +1,85 @@ +name: Tests on PR + +on: + workflow_call: + inputs: + project: + description: 'Name of the project to test' + default: 'PROJECT_NAME' + required: false + type: string + python_version: + description: 'Python version for Conda environment' + default: 3.13 + required: false + type: number + c_extension: + description: 'Whether the project has a C extension' + default: false + required: false + type: boolean + headless: + description: 'Whether to run headless tests' + default: false + required: false + type: boolean + run: + description: 'Extra CLI commands to run after installing the project' + default: 'echo "No extra commands"' + required: false + type: string + +jobs: + validate: + defaults: + run: + shell: bash -l {0} + + runs-on: ubuntu-latest + steps: + - name: Check out ${{ inputs.project }} + uses: actions/checkout@v4 + + - name: Initialize miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: test + channels: conda-forge + auto-update-conda: true + auto-activate-base: false + python-version: ${{ inputs.python_version }} + + - name: Conda config + run: >- + conda config --set always_yes yes + --set changeps1 no + + - name: Install ${{ inputs.project }} and requirements + run: | + conda install --file requirements/conda.txt + conda install --file requirements/tests.txt + if ${{ inputs.c_extension }}; then + conda install --file requirements/build.txt + fi + python -m pip install . --no-deps + + - name: Run extra user-defined CLI commands + run: | + echo "${{ inputs.run }}" > user-commands.sh + bash user-commands.sh + + - name: Start Xvfb + if: ${{ inputs.headless }} + run: | + sudo apt-get install -y xvfb + export DISPLAY=:99 + Xvfb :99 -screen 0 1024x768x16 & + + - name: Validate ${{ inputs.project }} + run: | + if ${{ inputs.headless }}; then + export DISPLAY=:99 + fi + pytest --cov + coverage report -m + codecov From 03e579c7b07b44a0315b6ef636c51e66f5676a89 Mon Sep 17 00:00:00 2001 From: Zhi Ming Xu Date: Sun, 13 Jul 2025 04:20:48 -0400 Subject: [PATCH 2/6] chore: add news file --- news/add-pdfgetx-workflow.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 news/add-pdfgetx-workflow.rst diff --git a/news/add-pdfgetx-workflow.rst b/news/add-pdfgetx-workflow.rst new file mode 100644 index 0000000..7dbec71 --- /dev/null +++ b/news/add-pdfgetx-workflow.rst @@ -0,0 +1,23 @@ +**Added:** + +* Add tests-on-pr workflow file that doesn't upload to codecov for private repos + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From cfe375175d00f91e3fa71443fa1c3685ddf7984f Mon Sep 17 00:00:00 2001 From: Zhi Ming Xu Date: Sun, 13 Jul 2025 19:58:51 -0400 Subject: [PATCH 3/6] refactor: create chained workflow calls for tests-on-pr --- .github/workflows/_tests-on-pr.yml | 74 +++++------------------- .github/workflows/_upload-to-codecov.yml | 19 ++++++ 2 files changed, 33 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/_upload-to-codecov.yml diff --git a/.github/workflows/_tests-on-pr.yml b/.github/workflows/_tests-on-pr.yml index 31bd2f1..7ccb69f 100644 --- a/.github/workflows/_tests-on-pr.yml +++ b/.github/workflows/_tests-on-pr.yml @@ -34,63 +34,17 @@ on: required: true jobs: - validate: - defaults: - run: - shell: bash -l {0} - - runs-on: ubuntu-latest - steps: - - name: Check out ${{ inputs.project }} - uses: actions/checkout@v4 - - - name: Initialize miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: test - channels: conda-forge - auto-update-conda: true - auto-activate-base: false - python-version: ${{ inputs.python_version }} - - - name: Conda config - run: >- - conda config --set always_yes yes - --set changeps1 no - - - name: Install ${{ inputs.project }} and requirements - run: | - conda install --file requirements/conda.txt - conda install --file requirements/tests.txt - if ${{ inputs.c_extension }}; then - conda install --file requirements/build.txt - fi - python -m pip install . --no-deps - - - name: Run extra user-defined CLI commands - run: | - echo "${{ inputs.run }}" > user-commands.sh - bash user-commands.sh - - - name: Start Xvfb - if: ${{ inputs.headless }} - run: | - sudo apt-get install -y xvfb - export DISPLAY=:99 - Xvfb :99 -screen 0 1024x768x16 & - - - name: Validate ${{ inputs.project }} - run: | - if ${{ inputs.headless }}; then - export DISPLAY=:99 - fi - pytest --cov - coverage report -m - codecov - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v5 - with: - verbose: true - fail_ci_if_error: true - token: ${{ secrets.CODECOV_TOKEN }} + run-tests: + uses: ./.github/workflows/_tests-on-pr-no-codecov.yml + with: + project: ${{ inputs.project }} + python_version: ${{ inputs.python_version }} + c_extension: ${{ inputs.c_extension }} + headless: ${{ inputs.headless }} + run: ${{ inputs.run }} + + upload-codecov: + needs: [run-tests] + uses: ./.github/workflows/_upload-to-codecov.yml + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/_upload-to-codecov.yml b/.github/workflows/_upload-to-codecov.yml new file mode 100644 index 0000000..a804431 --- /dev/null +++ b/.github/workflows/_upload-to-codecov.yml @@ -0,0 +1,19 @@ +name: Upload to Codecov + +on: + workflow_call: + secrets: + CODECOV_TOKEN: + description: 'Codecov token' + required: true + +jobs: + upload: + runs-on: ubuntu-latest + steps: + - name: Upload to Codecov + uses: codecov/codecov-action@v5 + with: + verbose: true + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} From e29b9c703e6af4a288379fa92514a6d36a5593e4 Mon Sep 17 00:00:00 2001 From: Zhi Ming Xu Date: Sun, 13 Jul 2025 20:01:36 -0400 Subject: [PATCH 4/6] chore: update news file --- news/add-pdfgetx-workflow.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/add-pdfgetx-workflow.rst b/news/add-pdfgetx-workflow.rst index 7dbec71..1faf97c 100644 --- a/news/add-pdfgetx-workflow.rst +++ b/news/add-pdfgetx-workflow.rst @@ -4,7 +4,7 @@ **Changed:** -* +* Create chained workflows for tests-on-pr.yml that calls tests-on-r-no-codecov.yml and upload-to-codecov.yml **Deprecated:** From 0d8b438efd605c9dd4cb70f209c464c17cd7483d Mon Sep 17 00:00:00 2001 From: Zhi Ming Xu Date: Sun, 13 Jul 2025 23:35:29 -0400 Subject: [PATCH 5/6] chore: change the syntax to call reusable workflow files --- .github/workflows/_tests-on-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_tests-on-pr.yml b/.github/workflows/_tests-on-pr.yml index 7ccb69f..2794d3a 100644 --- a/.github/workflows/_tests-on-pr.yml +++ b/.github/workflows/_tests-on-pr.yml @@ -35,7 +35,7 @@ on: jobs: run-tests: - uses: ./.github/workflows/_tests-on-pr-no-codecov.yml + uses: scikit-package/release-scripts/.github/workflows/_tests-on-pr-no-codecov.yml@v0 with: project: ${{ inputs.project }} python_version: ${{ inputs.python_version }} @@ -45,6 +45,6 @@ jobs: upload-codecov: needs: [run-tests] - uses: ./.github/workflows/_upload-to-codecov.yml + uses: scikit-package/release-scripts/.github/workflows/_upload-to-codecov.yml@v0 secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From c1f5a4bdace27e6cd408050697983aca1e656aa0 Mon Sep 17 00:00:00 2001 From: Zhi Ming Xu Date: Mon, 14 Jul 2025 13:44:29 -0400 Subject: [PATCH 6/6] chore: revert to previous workflow version without the chained workflows; update news file --- .github/workflows/_tests-on-pr.yml | 74 +++++++++++++++++++----- .github/workflows/_upload-to-codecov.yml | 19 ------ news/add-pdfgetx-workflow.rst | 2 +- 3 files changed, 61 insertions(+), 34 deletions(-) delete mode 100644 .github/workflows/_upload-to-codecov.yml diff --git a/.github/workflows/_tests-on-pr.yml b/.github/workflows/_tests-on-pr.yml index 2794d3a..31bd2f1 100644 --- a/.github/workflows/_tests-on-pr.yml +++ b/.github/workflows/_tests-on-pr.yml @@ -34,17 +34,63 @@ on: required: true jobs: - run-tests: - uses: scikit-package/release-scripts/.github/workflows/_tests-on-pr-no-codecov.yml@v0 - with: - project: ${{ inputs.project }} - python_version: ${{ inputs.python_version }} - c_extension: ${{ inputs.c_extension }} - headless: ${{ inputs.headless }} - run: ${{ inputs.run }} - - upload-codecov: - needs: [run-tests] - uses: scikit-package/release-scripts/.github/workflows/_upload-to-codecov.yml@v0 - secrets: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + validate: + defaults: + run: + shell: bash -l {0} + + runs-on: ubuntu-latest + steps: + - name: Check out ${{ inputs.project }} + uses: actions/checkout@v4 + + - name: Initialize miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: test + channels: conda-forge + auto-update-conda: true + auto-activate-base: false + python-version: ${{ inputs.python_version }} + + - name: Conda config + run: >- + conda config --set always_yes yes + --set changeps1 no + + - name: Install ${{ inputs.project }} and requirements + run: | + conda install --file requirements/conda.txt + conda install --file requirements/tests.txt + if ${{ inputs.c_extension }}; then + conda install --file requirements/build.txt + fi + python -m pip install . --no-deps + + - name: Run extra user-defined CLI commands + run: | + echo "${{ inputs.run }}" > user-commands.sh + bash user-commands.sh + + - name: Start Xvfb + if: ${{ inputs.headless }} + run: | + sudo apt-get install -y xvfb + export DISPLAY=:99 + Xvfb :99 -screen 0 1024x768x16 & + + - name: Validate ${{ inputs.project }} + run: | + if ${{ inputs.headless }}; then + export DISPLAY=:99 + fi + pytest --cov + coverage report -m + codecov + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + with: + verbose: true + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/_upload-to-codecov.yml b/.github/workflows/_upload-to-codecov.yml deleted file mode 100644 index a804431..0000000 --- a/.github/workflows/_upload-to-codecov.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Upload to Codecov - -on: - workflow_call: - secrets: - CODECOV_TOKEN: - description: 'Codecov token' - required: true - -jobs: - upload: - runs-on: ubuntu-latest - steps: - - name: Upload to Codecov - uses: codecov/codecov-action@v5 - with: - verbose: true - fail_ci_if_error: true - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/news/add-pdfgetx-workflow.rst b/news/add-pdfgetx-workflow.rst index 1faf97c..7dbec71 100644 --- a/news/add-pdfgetx-workflow.rst +++ b/news/add-pdfgetx-workflow.rst @@ -4,7 +4,7 @@ **Changed:** -* Create chained workflows for tests-on-pr.yml that calls tests-on-r-no-codecov.yml and upload-to-codecov.yml +* **Deprecated:**