From e927799b76510668a33d51b85a69040fa37609bb Mon Sep 17 00:00:00 2001 From: "Benjamin T. Schwertfeger" Date: Sat, 27 Jan 2024 09:20:25 +0100 Subject: [PATCH] adjust CI configuration (#187) --- .github/workflows/_build.yaml | 26 ++++++- .github/workflows/_build_doc.yaml | 4 +- .github/workflows/_codecov.yaml | 4 +- .github/workflows/_codeql.yaml | 8 +- .github/workflows/_pre_commit.yaml | 4 +- .github/workflows/_pypi_publish.yaml | 14 +++- .github/workflows/_test_futures_private.yaml | 4 +- .github/workflows/_test_futures_public.yaml | 4 +- .github/workflows/_test_spot_private.yaml | 4 +- .github/workflows/_test_spot_public.yaml | 4 +- .github/workflows/cicd.yaml | 81 +++++++++++--------- .github/workflows/codeql.yaml | 13 ---- .github/workflows/manual_build.yaml | 2 +- .github/workflows/manual_test_futures.yaml | 4 +- .github/workflows/manual_test_spot.yaml | 4 +- .gitignore | 1 - 16 files changed, 102 insertions(+), 79 deletions(-) delete mode 100644 .github/workflows/codeql.yaml diff --git a/.github/workflows/_build.yaml b/.github/workflows/_build.yaml index a24b5ade..54462e56 100644 --- a/.github/workflows/_build.yaml +++ b/.github/workflows/_build.yaml @@ -23,10 +23,10 @@ jobs: runs-on: ${{ inputs.os }} steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ inputs.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ inputs.python-version }} @@ -35,6 +35,28 @@ jobs: python -m pip install --upgrade pip python -m pip install build + - name: Check git status (not Windows) + if: runner.os != 'Windows' + run: | + if [[ -z "$(git status --porcelain)" ]]; then + echo "No changes found." + else + echo "Changes detected. Please commit or discard changes before publishing." + git status --porcelain + exit 1 + fi + + - name: Check git status (Windows) + if: runner.os == 'Windows' + run: | + if (-not (git status --porcelain)) { + Write-Output "No changes found." + } else { + Write-Output "Changes detected. Please commit or discard changes before publishing." + git status --porcelain + exit 1 + } + - name: Build the package run: python -m build --outdir . diff --git a/.github/workflows/_build_doc.yaml b/.github/workflows/_build_doc.yaml index e1b428f5..8313c3d8 100644 --- a/.github/workflows/_build_doc.yaml +++ b/.github/workflows/_build_doc.yaml @@ -22,10 +22,10 @@ jobs: runs-on: ${{ inputs.os }} steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ inputs.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ inputs.python-version }} diff --git a/.github/workflows/_codecov.yaml b/.github/workflows/_codecov.yaml index 5fd82f01..438adfb7 100644 --- a/.github/workflows/_codecov.yaml +++ b/.github/workflows/_codecov.yaml @@ -43,10 +43,10 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ inputs.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ inputs.python-version }} diff --git a/.github/workflows/_codeql.yaml b/.github/workflows/_codeql.yaml index 00668de0..f7acede0 100644 --- a/.github/workflows/_codeql.yaml +++ b/.github/workflows/_codeql.yaml @@ -25,11 +25,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: python # If you wish to specify custom queries, you can do so here or in a config file. @@ -42,7 +42,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -55,6 +55,6 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 with: category: "/language:python" diff --git a/.github/workflows/_pre_commit.yaml b/.github/workflows/_pre_commit.yaml index 3ae26786..487c5be2 100644 --- a/.github/workflows/_pre_commit.yaml +++ b/.github/workflows/_pre_commit.yaml @@ -14,6 +14,6 @@ jobs: Pre-Commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 - uses: pre-commit/action@v3.0.0 diff --git a/.github/workflows/_pypi_publish.yaml b/.github/workflows/_pypi_publish.yaml index c9156e71..779a0049 100644 --- a/.github/workflows/_pypi_publish.yaml +++ b/.github/workflows/_pypi_publish.yaml @@ -28,12 +28,12 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 # IMPORTANT: otherwise the current tag does not get fetched and the build version gets worse - name: Set up Python 3.11 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.11 @@ -42,6 +42,16 @@ jobs: python -m pip install --upgrade pip python -m pip install build + - name: Check git status + run: | + if [[ -z "$(git status --porcelain)" ]]; then + echo "No changes found." + else + echo "Changes detected. Please commit or discard changes before publishing." + git status --porcelain + exit 1 + fi + - name: Build the package run: python -m build . diff --git a/.github/workflows/_test_futures_private.yaml b/.github/workflows/_test_futures_private.yaml index a3d34280..e5bf5040 100644 --- a/.github/workflows/_test_futures_private.yaml +++ b/.github/workflows/_test_futures_private.yaml @@ -36,10 +36,10 @@ jobs: runs-on: ${{ inputs.os }} steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ inputs.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ inputs.python-version }} diff --git a/.github/workflows/_test_futures_public.yaml b/.github/workflows/_test_futures_public.yaml index 0b55aac0..56dac82b 100644 --- a/.github/workflows/_test_futures_public.yaml +++ b/.github/workflows/_test_futures_public.yaml @@ -26,10 +26,10 @@ jobs: runs-on: ${{ inputs.os }} steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ inputs.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ inputs.python-version }} diff --git a/.github/workflows/_test_spot_private.yaml b/.github/workflows/_test_spot_private.yaml index c7d77680..94d57445 100644 --- a/.github/workflows/_test_spot_private.yaml +++ b/.github/workflows/_test_spot_private.yaml @@ -33,10 +33,10 @@ jobs: runs-on: ${{ inputs.os }} steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ inputs.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ inputs.python-version }} diff --git a/.github/workflows/_test_spot_public.yaml b/.github/workflows/_test_spot_public.yaml index b221527b..6ed7a146 100644 --- a/.github/workflows/_test_spot_public.yaml +++ b/.github/workflows/_test_spot_public.yaml @@ -26,10 +26,10 @@ jobs: runs-on: ${{ inputs.os }} steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ inputs.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ inputs.python-version }} diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index 39bbf59d..10e9579d 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -79,7 +79,7 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.11"] + python-version: ["3.11", "3.12"] with: os: ${{ matrix.os }} python-version: ${{ matrix.python-version }} @@ -100,27 +100,27 @@ jobs: ## (public endpoints) ## Test-Spot-Public: - needs: [Build] + needs: [Pre-Commit] uses: ./.github/workflows/_test_spot_public.yaml strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] - python-version: ["3.11"] + python-version: ["3.11", "3.12"] with: os: ${{ matrix.os }} python-version: ${{ matrix.python-version }} ## ## (private endpoints) Test-Spot-Private: - needs: [Build] + needs: [Pre-Commit] uses: ./.github/workflows/_test_spot_private.yaml strategy: max-parallel: 1 # to avoid failing tests because of API Rate limits fail-fast: false matrix: os: [ubuntu-latest, windows-latest] - python-version: ["3.11"] + python-version: ["3.11", "3.12"] with: os: ${{ matrix.os }} python-version: ${{ matrix.python-version }} @@ -131,48 +131,68 @@ jobs: ## ## (public endpoints) Test-Futures-Public: - needs: [Build] + needs: [Pre-Commit] uses: ./.github/workflows/_test_futures_public.yaml strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] - python-version: ["3.11"] + python-version: ["3.11", "3.12"] with: os: ${{ matrix.os }} python-version: ${{ matrix.python-version }} ## ## (private endpoints) Test-Futures-Private: - needs: [Build] + needs: [Pre-Commit] uses: ./.github/workflows/_test_futures_private.yaml strategy: max-parallel: 1 # to avoid failing tests because of API Rate limits fail-fast: false matrix: os: [ubuntu-latest, windows-latest] - python-version: ["3.11"] + python-version: ["3.11", "3.12"] with: os: ${{ matrix.os }} python-version: ${{ matrix.python-version }} secrets: inherit ## =========================================================================== - ## Uploads the package to test.pypi.org on master if triggered by - ## a regular commit/push. + ## Generates and uploads the coverage statistics to codecov ## - UploadTestPyPI: + CodeCov: if: | - success() && - github.actor == 'btschwertfeger' && - github.ref == 'refs/heads/master' && - github.event_name == 'push' + (success() && github.actor == 'btschwertfeger') + && (github.event_name == 'push' || github.event_name == 'release') needs: - Test-Spot-Public - Test-Spot-Private - Test-Futures-Public - Test-Futures-Private - name: Upload current development version to Test PyPI + uses: ./.github/workflows/_codecov.yaml + with: + os: "ubuntu-latest" + python-version: "3.11" + secrets: inherit + + ## =========================================================================== + ## Uploads the package to test.pypi.org on master if triggered by + ## a regular commit/push. + ## + UploadTestPyPI: + if: | + ( + success() + && github.actor == 'btschwertfeger' + && github.ref == 'refs/heads/master' + ) + && (github.event_name == 'push' || github.event_name == 'release') + needs: + - Build + - Build-Doc + - CodeQL + - CodeCov + name: Upload development version to Test PyPI uses: ./.github/workflows/_pypi_publish.yaml with: REPOSITORY_URL: https://test.pypi.org/legacy/ @@ -187,29 +207,14 @@ jobs: success() && github.actor == 'btschwertfeger' && github.event_name == 'release' - needs: [UploadTestPyPI] - name: Upload the current release to PyPI + needs: + - Build + - Build-Doc + - CodeQL + - CodeCov + name: Upload release to PyPI uses: ./.github/workflows/_pypi_publish.yaml with: REPOSITORY_URL: https://upload.pypi.org/legacy/ secrets: API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} - - ## =========================================================================== - ## Generates and uploads the coverage statistics to codecov - ## - CodeCov: - if: | - success() && - github.actor == 'btschwertfeger' && - github.event_name == 'push' - needs: - - Test-Spot-Public - - Test-Spot-Private - - Test-Futures-Public - - Test-Futures-Private - uses: ./.github/workflows/_codecov.yaml - with: - os: "ubuntu-latest" - python-version: "3.11" - secrets: inherit diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml deleted file mode 100644 index 02e06fbd..00000000 --- a/.github/workflows/codeql.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: "CodeQL" - -on: - schedule: - - cron: "0 0 * * 0" - -concurrency: - group: CodeQL-${{ github.ref }} - cancel-in-progress: true - -jobs: - CodeQL: - uses: ./.github/workflows/_codeql.yaml diff --git a/.github/workflows/manual_build.yaml b/.github/workflows/manual_build.yaml index 32812e7e..fbb90bce 100644 --- a/.github/workflows/manual_build.yaml +++ b/.github/workflows/manual_build.yaml @@ -18,7 +18,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] - python-version: ["3.11"] + python-version: ["3.11", "3.12"] with: os: ${{ matrix.os }} python-version: ${{ matrix.python-version }} diff --git a/.github/workflows/manual_test_futures.yaml b/.github/workflows/manual_test_futures.yaml index 186362aa..82bd2a2b 100644 --- a/.github/workflows/manual_test_futures.yaml +++ b/.github/workflows/manual_test_futures.yaml @@ -34,7 +34,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.11"] + python-version: ["3.11", "3.12"] with: os: ${{ matrix.os }} python-version: ${{ matrix.python-version }} @@ -46,7 +46,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.11"] + python-version: ["3.11", "3.12"] with: os: ${{ matrix.os }} python-version: ${{ matrix.python-version }} diff --git a/.github/workflows/manual_test_spot.yaml b/.github/workflows/manual_test_spot.yaml index a2ad069c..b88215f7 100644 --- a/.github/workflows/manual_test_spot.yaml +++ b/.github/workflows/manual_test_spot.yaml @@ -42,7 +42,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.11"] + python-version: ["3.11", "3.12"] with: os: ${{ matrix.os }} python-version: ${{ matrix.python-version }} @@ -54,7 +54,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.11"] + python-version: ["3.11", "3.12"] with: os: ${{ matrix.os }} python-version: ${{ matrix.python-version }} diff --git a/.gitignore b/.gitignore index 830f57fc..74412e73 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,6 @@ __pycache__/ *$py.class # C extensions *.so -*.zip # Distribution / packaging .Python