From 815324b781c9c75da86c3c7315b547a31a62733d Mon Sep 17 00:00:00 2001 From: "Benjamin T. Schwertfeger" Date: Mon, 13 Jan 2025 18:36:40 +0100 Subject: [PATCH] Fix the docker image upload (#53) --- .github/workflows/_docker_publish.yaml | 11 ++- .github/workflows/cicd.yaml | 11 ++- .github/workflows/scorecard.yaml | 79 +++++++++++++++++++ .../integration/test_integration_GridHODL.py | 1 - 4 files changed, 95 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/scorecard.yaml diff --git a/.github/workflows/_docker_publish.yaml b/.github/workflows/_docker_publish.yaml index 5aacec5..8e3902e 100644 --- a/.github/workflows/_docker_publish.yaml +++ b/.github/workflows/_docker_publish.yaml @@ -8,6 +8,11 @@ name: Build and push Docker image on: workflow_call: + secrets: + DOCKERHUB_USERNAME: + required: true + DOCKERHUB_TOKEN: + required: true env: REGISTRY: ghcr.io @@ -37,8 +42,8 @@ jobs: - name: Log in to Docker Hub uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_TOKEN }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Log in to the Container registry uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 @@ -52,7 +57,7 @@ jobs: uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: images: | - btschwertfeger/kraken-infinity-grid + ${{ env.IMAGE_NAME }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push Docker images diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index d03d952..85c35dc 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -72,7 +72,7 @@ jobs: ## Run the unit and integration tests ## Test: - needs: [Build] + needs: [Pre-Commit] uses: ./.github/workflows/_test.yaml strategy: fail-fast: true @@ -91,8 +91,7 @@ jobs: success() && github.actor == 'btschwertfeger' && github.event_name != 'schedule' - needs: - - Test + needs: [Pre-Commit] uses: ./.github/workflows/_codecov.yaml with: os: "ubuntu-latest" @@ -115,6 +114,7 @@ jobs: - Build-Docker - CodeCov - CodeQL + - Test uses: ./.github/workflows/_pypi_test_publish.yaml secrets: API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }} @@ -133,6 +133,7 @@ jobs: - Build-Docker - CodeCov - CodeQL + - Test uses: ./.github/workflows/_pypi_publish.yaml secrets: API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} @@ -154,4 +155,8 @@ jobs: - Build-Docker - CodeCov - CodeQL + - Test uses: ./.github/workflows/_docker_publish.yaml + secrets: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/scorecard.yaml b/.github/workflows/scorecard.yaml new file mode 100644 index 0000000..08ec517 --- /dev/null +++ b/.github/workflows/scorecard.yaml @@ -0,0 +1,79 @@ +# This workflow uses actions that are not certified by GitHub. They are provided +# by a third-party and are governed by separate terms of service, privacy +# policy, and support documentation. + +name: Scorecard supply-chain security + +on: + # For Branch-Protection check. Only the default branch is supported. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection + branch_protection_rule: + # To guarantee Maintained check is occasionally updated. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained + schedule: + - cron: "15 5 * * 7" + push: + branches: ["master"] + +# Declare default permissions as read only. +permissions: read-all + +jobs: + analysis: + name: Scorecard analysis + runs-on: ubuntu-latest + permissions: + # Needed to upload the results to code-scanning dashboard. + security-events: write + # Needed to publish results and get a badge (see publish_results below). + id-token: write + # Uncomment the permissions below if installing in a private repository. + # contents: read + # actions: read + + steps: + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + fetch-depth: 0 # IMPORTANT: otherwise the current tag does not get fetched and the build version gets worse + + - name: Run analysis + uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 + with: + results_file: results.sarif + results_format: sarif + # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: + # - you want to enable the Branch-Protection check on a *public* repository, or + # - you are installing Scorecard on a *private* repository + # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. + # repo_token: ${{ secrets.SCORECARD_TOKEN }} + + # Public repositories: + # - Publish results to OpenSSF REST API for easy access by consumers + # - Allows the repository to include the Scorecard badge. + # - See https://github.com/ossf/scorecard-action#publishing-results. + # For private repositories: + # - `publish_results` will always be set to `false`, regardless + # of the value entered here. + publish_results: true + + # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF + # format to the repository Actions tab. + - name: Upload artifact + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + with: + name: SARIF file + path: results.sarif + retention-days: 5 + + # Upload the results to GitHub's code scanning dashboard. + - name: Upload to code-scanning + uses: github/codeql-action/upload-sarif@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0 + with: + sarif_file: results.sarif diff --git a/tests/integration/test_integration_GridHODL.py b/tests/integration/test_integration_GridHODL.py index 9d5403f..6a63448 100644 --- a/tests/integration/test_integration_GridHODL.py +++ b/tests/integration/test_integration_GridHODL.py @@ -123,7 +123,6 @@ async def test_integration_GridHODL( # noqa: PLR0915 # Quick re-check ... the price update should not affect any orderbook # changes when dropping. - current_orders = instance.orderbook.get_orders().all() for order, price, volume in zip( instance.orderbook.get_orders().all(), (59405.9, 58817.7, 58235.3, 57658.7, 57087.8),