diff --git a/.github/actions/hugo-build-action/action.yaml b/.github/actions/hugo-build-action/action.yaml index 45f154f71..bea0cd82c 100644 --- a/.github/actions/hugo-build-action/action.yaml +++ b/.github/actions/hugo-build-action/action.yaml @@ -9,34 +9,31 @@ runs: using: "composite" steps: - name: "Setup GO" - uses: actions/setup-go@v6 + uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0 with: go-version: '>=1.20.1' cache: false - name: "Cache Go modules" - uses: actions/cache@v5 + uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0 with: path: ~/go/pkg/mod key: go-mod-${{ hashFiles('docs/go.sum') }} restore-keys: go-mod- - name: "Setup Node" - uses: actions/setup-node@v5 + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 with: node-version: 20 cache: 'npm' cache-dependency-path: docs/package-lock.json - - name: "Install Hugo" - shell: bash - working-directory: ./docs - run: | - npm install -g hugo-extended@0.117.0 + # docs/package-lock.json pins hugo-extended, so npm ci installs the hugo binary that + # the build step runs with npx. - name: "Install Dependencies" shell: bash working-directory: ./docs run: | npm ci - name: "Cache Hugo resources" - uses: actions/cache@v5 + uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0 with: path: docs/resources/_gen key: hugo-resources-${{ hashFiles('docs/go.sum', 'docs/config/**') }} @@ -47,4 +44,4 @@ runs: BASE_URL: ${{ inputs.base-url }} shell: bash run: | - hugo --minify ${BASE_URL:+--baseURL $BASE_URL} -e _default + npx --no hugo --minify ${BASE_URL:+--baseURL $BASE_URL} -e _default diff --git a/.github/actions/hugo-build-versioned-action/action.yaml b/.github/actions/hugo-build-versioned-action/action.yaml index 8f36cce2f..933e282d2 100644 --- a/.github/actions/hugo-build-versioned-action/action.yaml +++ b/.github/actions/hugo-build-versioned-action/action.yaml @@ -20,9 +20,11 @@ inputs: runs: using: "composite" steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 + with: + persist-credentials: false - name: Setup Python - uses: actions/setup-python@v6 + uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: python-version-file: ".python-version" cache: 'pip' @@ -32,27 +34,24 @@ runs: run: | python -m pip install --upgrade pip pip install -r scripts/script-requirements.txt - - uses: actions/setup-go@v6 + - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0 with: go-version: '>=1.20.1' cache: false - name: "Cache Go modules" - uses: actions/cache@v5 + uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0 with: path: ~/go/pkg/mod key: go-mod-${{ hashFiles('docs/go.sum') }} restore-keys: go-mod- - name: "Setup Node" - uses: actions/setup-node@v5 + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 with: node-version: 20 cache: 'npm' cache-dependency-path: docs/package-lock.json - - name: "Install Hugo" - shell: bash - working-directory: ./docs - run: | - npm install -g hugo-extended@0.117.0 + # docs/package-lock.json pins hugo-extended, so npm ci installs the hugo binary that + # the build step runs with npx. - name: "Install Dependencies" working-directory: ./docs shell: bash @@ -65,9 +64,11 @@ runs: rm -f generate.sh wget https://raw.githubusercontent.com/gooddata/gooddata-python-sdk/master/scripts/generate.sh chmod +x ./generate.sh - ./generate.sh ${{ inputs.fetch-from }} master + ./generate.sh ${INPUTS_FETCH_FROM} master + env: + INPUTS_FETCH_FROM: ${{ inputs.fetch-from }} - name: "Cache Hugo resources" - uses: actions/cache@v5 + uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0 with: path: docs/resources/_gen key: hugo-resources-${{ hashFiles('docs/go.sum', 'docs/config/**') }} @@ -80,4 +81,4 @@ runs: HUGO_ENV: ${{ inputs.hugo-env }} shell: bash run: | - hugo --minify ${BASE_URL:+--baseURL $BASE_URL} + npx --no hugo --minify ${BASE_URL:+--baseURL $BASE_URL} diff --git a/.github/actions/merge/action.yaml b/.github/actions/merge/action.yaml index aa8908a2b..ead29d3c4 100644 --- a/.github/actions/merge/action.yaml +++ b/.github/actions/merge/action.yaml @@ -29,18 +29,19 @@ inputs: runs: using: "composite" steps: - - name: Checkout source branch - uses: actions/checkout@v5 + # The next step pushes the snapshot branch with these credentials. + - name: Checkout source branch # zizmor: ignore[artipacked] + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: fetch-depth: 0 ref: "${{ inputs.source }}" token: "${{ inputs.token_push }}" - name: Checkout and push new branch run: | - commit=$(git log --until="${{ inputs.cutoff }}" --format="%H" -n 1) + commit=$(git log --until="${INPUTS_CUTOFF}" --format="%H" -n 1) git checkout $commit short=$(git rev-parse --short HEAD) - branch="snapshot-${{ inputs.source }}-${short}-to-${{ inputs.target }}" + branch="snapshot-${INPUTS_SOURCE}-${short}-to-${INPUTS_TARGET}" git checkout -b $branch git push origin $branch echo "commit=${commit}" >> $GITHUB_OUTPUT @@ -48,16 +49,24 @@ runs: echo "branch=${branch}" >> $GITHUB_OUTPUT shell: bash id: push + env: + INPUTS_CUTOFF: ${{ inputs.cutoff }} + INPUTS_SOURCE: ${{ inputs.source }} + INPUTS_TARGET: ${{ inputs.target }} - name: Create the promote/backmerge PR run: | gh pr create \ - --title "[bot] Merge ${{ inputs.source }}/${{ steps.push.outputs.short }} into ${{ inputs.target }}" \ - --body ":rocket: Automated PR to perform merge from **${{ inputs.source }}** into **${{ inputs.target }}** with changes up to ${{ steps.push.outputs.short }} (created by ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})." \ - --base ${{ inputs.target }} --head ${{ steps.push.outputs.branch }} \ + --title "[bot] Merge ${INPUTS_SOURCE}/${STEPS_PUSH_OUTPUTS_SHORT} into ${INPUTS_TARGET}" \ + --body ":rocket: Automated PR to perform merge from **${INPUTS_SOURCE}** into **${INPUTS_TARGET}** with changes up to ${STEPS_PUSH_OUTPUTS_SHORT} (created by ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})." \ + --base ${INPUTS_TARGET} --head ${STEPS_PUSH_OUTPUTS_BRANCH} \ | tee -a $GITHUB_STEP_SUMMARY shell: bash env: GH_TOKEN: ${{ inputs.token_pr }} + INPUTS_SOURCE: ${{ inputs.source }} + STEPS_PUSH_OUTPUTS_SHORT: ${{ steps.push.outputs.short }} + INPUTS_TARGET: ${{ inputs.target }} + STEPS_PUSH_OUTPUTS_BRANCH: ${{ steps.push.outputs.branch }} - name: Merge the created PR if: ${{ inputs.merge == 'true' }} run: gh pr merge --merge --admin --delete-branch diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml index 922dbca99..290e06562 100644 --- a/.github/workflows/build-release.yaml +++ b/.github/workflows/build-release.yaml @@ -37,6 +37,8 @@ concurrency: group: build-release-${{ github.event_name }} cancel-in-progress: false +permissions: {} + env: COMPONENTS: '["gooddata-api-client","gooddata-pandas","gooddata-fdw","gooddata-sdk","gooddata-dbt","gooddata-flight-server","gooddata-flexconnect","gooddata-pipelines","gooddata-eval"]' @@ -63,7 +65,7 @@ jobs: # and the version to start from. - name: Checkout the workflow revision if: github.event_name == 'workflow_dispatch' - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: persist-credentials: false - name: Compute dev version @@ -91,12 +93,12 @@ jobs: component: ${{ fromJSON(needs.matrix-components.outputs.components) }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: ref: ${{ needs.matrix-components.outputs.ref }} persist-credentials: false - name: Install uv - uses: astral-sh/setup-uv@v10.0.1 + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 with: prune-cache: true - name: Bump to dev version @@ -108,14 +110,16 @@ jobs: uv run tbump --only-patch --non-interactive "$DEV_VERSION" - name: Build ${{ matrix.component }} run: | - if [ "${{ matrix.component }}" = "gooddata-api-client" ]; then - cd ${{ matrix.component }} + if [ "${MATRIX_COMPONENT}" = "gooddata-api-client" ]; then + cd ${MATRIX_COMPONENT} else - cd packages/${{ matrix.component }} + cd packages/${MATRIX_COMPONENT} fi uv build --out-dir dist + env: + MATRIX_COMPONENT: ${{ matrix.component }} - name: Persist ${{ matrix.component }} artifacts - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: name: artifacts_${{ matrix.component }} path: | @@ -132,9 +136,10 @@ jobs: is_latest: ${{ steps.check.outputs.is_latest }} steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: fetch-depth: 0 # the checks need every tag and the default branch + persist-credentials: false - id: check uses: ./.github/actions/release-tag-checks @@ -149,12 +154,12 @@ jobs: contents: write steps: - name: Obtain artifacts - uses: actions/download-artifact@v6 + uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 with: path: dist/ - name: Generate changelog id: changelog - uses: requarks/changelog-action@v1 + uses: requarks/changelog-action@7ce6be4c4d2233ae2a943694ca34f23aeafa1054 # v1.11.0 with: token: "${{ secrets.GITHUB_TOKEN }}" tag: ${{ github.ref_name }} @@ -162,7 +167,7 @@ jobs: includeRefIssues: false useGitmojis: false - name: Create GitHub release - uses: "softprops/action-gh-release@v2" + uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2 with: body: ${{ steps.changelog.outputs.changes }} token: "${{ secrets.GITHUB_TOKEN }}" @@ -187,12 +192,12 @@ jobs: component: ${{ fromJSON(needs.matrix-components.outputs.components) }} steps: - name: Obtain ${{ matrix.component }} artifacts - uses: actions/download-artifact@v6 + uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 with: name: artifacts_${{ matrix.component }} path: dist/${{ matrix.component }} - name: Push ${{ matrix.component}} to pypi - uses: pypa/gh-action-pypi-publish@release/v1 + uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3 with: packages-dir: dist/${{ matrix.component }} verbose: true @@ -200,9 +205,10 @@ jobs: if: github.event_name == 'push' runs-on: ubuntu-latest needs: publish + permissions: {} steps: - name: Notify to slack - uses: slackapi/slack-github-action@v2.0.0 + uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0 with: method: chat.postMessage token: ${{ secrets.SLACK_BOT_TOKEN }} diff --git a/.github/workflows/bump-version.yaml b/.github/workflows/bump-version.yaml index 204d40dc1..e57fcb226 100644 --- a/.github/workflows/bump-version.yaml +++ b/.github/workflows/bump-version.yaml @@ -30,13 +30,14 @@ jobs: bump-version: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v5 + # The job pushes the bump commit and the tag with the persisted credentials. + - name: Checkout # zizmor: ignore[artipacked] + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: token: ${{ secrets.TOKEN_GITHUB_YENKINS_ADMIN }} # needed to push to the protected branch - name: Install uv - uses: astral-sh/setup-uv@v10.0.1 + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 with: prune-cache: true @@ -47,16 +48,22 @@ jobs: - name: Bump version id: bump run: | - NEW_VERSION=$(uv run python ./scripts/bump_version.py ${{ github.event.inputs.bump_type }}) + NEW_VERSION=$(uv run python ./scripts/bump_version.py ${GITHUB_EVENT_INPUTS_BUMP_TYPE}) echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT" + env: + GITHUB_EVENT_INPUTS_BUMP_TYPE: ${{ github.event.inputs.bump_type }} - name: Bump version in documentation run: | - uv run python ./scripts/bump_doc_dependencies.py ${{ steps.bump.outputs.new_version }} + uv run python ./scripts/bump_doc_dependencies.py ${STEPS_BUMP_OUTPUTS_NEW_VERSION} + env: + STEPS_BUMP_OUTPUTS_NEW_VERSION: ${{ steps.bump.outputs.new_version }} - name: Bump version in codebase run: | - make release-ci VERSION=${{ steps.bump.outputs.new_version }} + make release-ci VERSION=${STEPS_BUMP_OUTPUTS_NEW_VERSION} + env: + STEPS_BUMP_OUTPUTS_NEW_VERSION: ${{ steps.bump.outputs.new_version }} - name: Create and push the new version ${{steps.bump.outputs.new_version}} env: diff --git a/.github/workflows/fossa.yaml b/.github/workflows/fossa.yaml index 5a1f1a35e..c8bf81964 100644 --- a/.github/workflows/fossa.yaml +++ b/.github/workflows/fossa.yaml @@ -40,9 +40,10 @@ jobs: - { path: gooddata-api-client, project: gooddata-api-client } steps: - name: Checkout the code - uses: actions/checkout@v6 + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 with: fetch-depth: 0 + persist-credentials: false - name: Scope .fossa.yml to ${{ matrix.package.project }} shell: bash @@ -72,7 +73,7 @@ jobs: [ -f ./requirements.txt ] || touch ./requirements.txt - name: Run FOSSA analyze - uses: fossas/fossa-action@v1.9.0 + uses: fossas/fossa-action@ff70fe9fe17cbd2040648f1c45e8ec4e4884dcf3 # v1.9.0 with: api-key: ${{ secrets.FOSSA_API_KEY }} branch: ${{ inputs.branch != '' && inputs.branch || github.ref_name }} @@ -81,7 +82,7 @@ jobs: # --branch flag (only `fossa analyze` does), so the branch input is # intentionally omitted here to avoid an "Invalid option `--branch'" error. - name: Run FOSSA test (policy gate) - uses: fossas/fossa-action@v1.9.0 + uses: fossas/fossa-action@ff70fe9fe17cbd2040648f1c45e8ec4e4884dcf3 # v1.9.0 with: api-key: ${{ secrets.FOSSA_API_KEY }} run-tests: true diff --git a/.github/workflows/netlify-deploy-preview.yaml b/.github/workflows/netlify-deploy-preview.yaml index 67b999779..86a2a9d1a 100644 --- a/.github/workflows/netlify-deploy-preview.yaml +++ b/.github/workflows/netlify-deploy-preview.yaml @@ -1,5 +1,8 @@ name: Netlify Deploy Preview -on: +# pull_request_target gives the job the Netlify token for pull requests from forks too. +# Nothing from the pull request runs: the job builds this repository's base branch, with +# only the Markdown under docs/content/en copied from the pull request's head. +on: # zizmor: ignore[dangerous-triggers] pull_request_target: branches: - 'rel/**' @@ -10,32 +13,39 @@ on: env: GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }} NETLIFY_SITE_NAME: ${{ github.event.repository.name }} + +permissions: {} + jobs: netlify-deploy: + permissions: + contents: read runs-on: group: infra1-runners-arc labels: runners-rxa-xlarge steps: - name: "Checkout Recursive" - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: submodules: recursive + persist-credentials: false - name: "Checkout to PR-tmp" - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} path: 'PR-tmp' + persist-credentials: false - name: "Get only changed docs" run: | rsync --delete -av PR-tmp/docs/content/en/ docs/content/en/ rm -rf PR-tmp - name: "Generate Docs" - uses: gooddata/gooddata-python-sdk/.github/actions/hugo-build-action@master + uses: ./.github/actions/hugo-build-action with: base-url: https://preview-${{ env.GITHUB_PR_NUMBER }}--${{ env.NETLIFY_SITE_NAME }}.netlify.app - name: "Publish" - uses: netlify/actions/cli@master + uses: netlify/actions/cli@3185065f4ab2f6df6f2ef41ee013626e1c02a426 # master with: args: deploy -d docs/public --alias=preview-${{ env.GITHUB_PR_NUMBER }} env: diff --git a/.github/workflows/netlify-deploy-v2.yaml b/.github/workflows/netlify-deploy-v2.yaml index d29c2a4ea..c1a130079 100644 --- a/.github/workflows/netlify-deploy-v2.yaml +++ b/.github/workflows/netlify-deploy-v2.yaml @@ -5,15 +5,21 @@ name: Netlify Deploy V2 (Draft) on: workflow_dispatch: +permissions: {} + jobs: # Job 1: Discover which version branches to build discover-versions: runs-on: ubuntu-latest + permissions: + contents: read outputs: matrix: ${{ steps.versions.outputs.matrix }} steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 + with: + persist-credentials: false - name: Fetch remote refs run: git fetch origin - name: Discover versions @@ -29,6 +35,8 @@ jobs: generate-version: needs: [discover-versions] runs-on: ubuntu-latest + permissions: + contents: read strategy: matrix: version: ${{ fromJson(needs.discover-versions.outputs.matrix) }} @@ -44,13 +52,15 @@ jobs: echo "Branch ${{ matrix.version.branch }} -> section ${{ matrix.version.section }} (SHA: $SHA)" - name: Cache version docs id: cache - uses: actions/cache@v5 + uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0 with: path: docs/versioned_docs/${{ matrix.version.section }} key: version-docs-${{ hashFiles('scripts/docs/*.py', 'scripts/docs/templates/**', 'docs/*_template.md', 'docs/layouts/shortcodes/**') }}-${{ matrix.version.section }}-${{ steps.sha.outputs.sha }} - name: Checkout if: steps.cache.outputs.cache-hit != 'true' - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 + with: + persist-credentials: false - name: Fetch target branch if: steps.cache.outputs.cache-hit != 'true' run: git fetch origin ${{ matrix.version.branch }} @@ -60,7 +70,7 @@ jobs: git checkout origin/${{ matrix.version.branch }} -- gooddata-api-client/ packages/gooddata-sdk/ packages/gooddata-pandas/ - name: Setup Python if: steps.cache.outputs.cache-hit != 'true' - uses: actions/setup-python@v6 + uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: python-version-file: ".python-version" cache: 'pip' @@ -74,7 +84,7 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: bash scripts/generate-single-version.sh "origin/${{ matrix.version.branch }}" "${{ matrix.version.section }}" - name: Upload version artifact - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 with: name: version-${{ matrix.version.section }} path: docs/versioned_docs/${{ matrix.version.section }} @@ -84,35 +94,38 @@ jobs: build-and-deploy: needs: [generate-version] runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: submodules: recursive + persist-credentials: false - name: Setup GO - uses: actions/setup-go@v6 + uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0 with: go-version: '>=1.20.1' cache: false - name: Cache Go modules - uses: actions/cache@v5 + uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0 with: path: ~/go/pkg/mod key: go-mod-${{ hashFiles('docs/go.sum') }} restore-keys: go-mod- - name: Setup Node - uses: actions/setup-node@v5 + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 with: node-version: 20 cache: 'npm' cache-dependency-path: docs/package-lock.json - - name: Install Hugo - run: npm install -g hugo-extended@0.117.0 + # docs/package-lock.json pins hugo-extended, so npm ci installs the hugo binary that + # the build step runs with npx. - name: Install Dependencies working-directory: ./docs run: npm ci - name: Download version artifacts - uses: actions/download-artifact@v6 + uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 with: pattern: version-* path: docs/versioned_docs-raw/ @@ -120,7 +133,7 @@ jobs: working-directory: ./docs run: bash ../scripts/assemble-versions.sh - name: Cache Hugo resources - uses: actions/cache@v5 + uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0 with: path: docs/resources/_gen key: hugo-resources-${{ hashFiles('docs/go.sum', 'docs/config/**') }} @@ -129,9 +142,9 @@ jobs: working-directory: ./docs env: HUGO_ENV: production - run: hugo --minify + run: npx --no hugo --minify - name: Publish (draft) - uses: netlify/actions/cli@master + uses: netlify/actions/cli@3185065f4ab2f6df6f2ef41ee013626e1c02a426 # master with: args: deploy -d docs/public env: diff --git a/.github/workflows/netlify-deploy.yaml b/.github/workflows/netlify-deploy.yaml index 4ada217a9..5e0edb21e 100644 --- a/.github/workflows/netlify-deploy.yaml +++ b/.github/workflows/netlify-deploy.yaml @@ -15,6 +15,8 @@ concurrency: group: netlify-prod cancel-in-progress: false +permissions: {} + jobs: tag-checks: name: Check the triggering tag @@ -25,9 +27,10 @@ jobs: is_on_master: ${{ steps.check.outputs.is_on_master }} steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: fetch-depth: 0 # the checks need every tag and the default branch + persist-credentials: false - id: check uses: ./.github/actions/release-tag-checks @@ -38,17 +41,20 @@ jobs: needs: tag-checks if: needs.tag-checks.outputs.is_on_master == 'true' runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: submodules: recursive + persist-credentials: false - name: Hugo Build - uses: gooddata/gooddata-python-sdk/.github/actions/hugo-build-versioned-action@master + uses: ./.github/actions/hugo-build-versioned-action with: base-url: https://www.gooddata.ai/docs/python-sdk - name: Publish - uses: netlify/actions/cli@master + uses: netlify/actions/cli@3185065f4ab2f6df6f2ef41ee013626e1c02a426 # master with: args: deploy -d docs/public --prod env: diff --git a/.github/workflows/pre-merge.yaml b/.github/workflows/pre-merge.yaml index 10539849a..2263da401 100644 --- a/.github/workflows/pre-merge.yaml +++ b/.github/workflows/pre-merge.yaml @@ -10,6 +10,8 @@ concurrency: group: ${{ github.event.number }} cancel-in-progress: true +permissions: {} + jobs: collect-changes: name: Collect changes @@ -23,25 +25,38 @@ jobs: test-python: name: Python tests needs: [ collect-changes ] + permissions: + contents: read uses: ./.github/workflows/rw-python-tests.yaml with: changed-python-modules: ${{ needs.collect-changes.outputs.changed-python-modules }} - secrets: inherit + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + lint-workflows: + name: GitHub Actions lint + needs: [ collect-changes ] + permissions: + contents: read + uses: ./.github/workflows/rw-workflow-lint.yaml + with: + changed-workflows: ${{ needs.collect-changes.outputs.changed-workflows }} status-check: # do not change the name of this job, it is used by the required status check # in GitHub, you WILL break merging if you change it name: status-check + permissions: {} runs-on: group: infra1-runners-arc labels: runners-small if: always() needs: + - lint-workflows - test-python steps: - name: Decide whether the needed jobs succeeded or failed - uses: re-actors/alls-green@release/v1 + uses: re-actors/alls-green@b5b5b37504aa4183270bd3d855c52a67f212be35 # v1.3.0 with: allowed-skips: ${{ toJSON(needs) }} jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/rel-dev-back-merge.yaml b/.github/workflows/rel-dev-back-merge.yaml index 2002009e7..f2d702a73 100644 --- a/.github/workflows/rel-dev-back-merge.yaml +++ b/.github/workflows/rel-dev-back-merge.yaml @@ -16,7 +16,9 @@ jobs: group: infra1-runners-arc labels: runners-small steps: - - uses: gooddata/gooddata-python-sdk/.github/actions/merge@master + # The job does not check out the repository, so the action cannot be referenced + # as ./.github/actions/merge. It always runs from master, the branch being merged. + - uses: gooddata/gooddata-python-sdk/.github/actions/merge@master # zizmor: ignore[unpinned-uses] with: merge: true source: "master" diff --git a/.github/workflows/rw-collect-changes.yaml b/.github/workflows/rw-collect-changes.yaml index 481501721..114abe90a 100644 --- a/.github/workflows/rw-collect-changes.yaml +++ b/.github/workflows/rw-collect-changes.yaml @@ -13,6 +13,9 @@ on: changed-python-modules: description: "Indicator of whether Python files or related config changed." value: ${{ jobs.collect-changes.outputs.python-modules}} + changed-workflows: + description: "Indicator of whether GitHub Actions workflows, actions or their lint config changed." + value: ${{ jobs.collect-changes.outputs.workflows}} jobs: collect-changes: @@ -22,13 +25,15 @@ jobs: outputs: docs: "${{ steps.filter.outputs.docs}}" python-modules: "${{ steps.filter.outputs.python-modules}}" + workflows: "${{ steps.filter.outputs.workflows}}" steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: fetch-depth: 0 + persist-credentials: false - - uses: dorny/paths-filter@v3 + - uses: dorny/paths-filter@0e4a8c6effa4802afeda77dc8d303f8176d7dfad # v3.0.4 id: filter with: base: ${{ inputs.commit-branch }} @@ -48,3 +53,10 @@ jobs: - Dockerfile - pyproject.toml - 'gooddata-api-client/**' + workflows: + - '.github/workflows/**' + # zizmor audits the local actions too + - '.github/actions/**' + - .github/zizmor.yml + # sets the zizmor version, and zizmor audits it + - .pre-commit-config.yaml diff --git a/.github/workflows/rw-python-tests.yaml b/.github/workflows/rw-python-tests.yaml index f429c5774..f2a8d324c 100644 --- a/.github/workflows/rw-python-tests.yaml +++ b/.github/workflows/rw-python-tests.yaml @@ -5,6 +5,9 @@ on: changed-python-modules: type: string default: 'false' + secrets: + CODECOV_TOKEN: + required: false jobs: unit-tests: runs-on: ubuntu-latest @@ -14,7 +17,9 @@ jobs: python_version: [py315, py314, py313, py312, py311] steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 + with: + persist-credentials: false - name: Execute tests run: | make test-ci @@ -22,7 +27,7 @@ jobs: TEST_ENVS: ${{ matrix.python_version }} - name: Upload coverage to Codecov if: ${{ matrix.python_version == 'py314' }} - uses: codecov/codecov-action@v5 + uses: codecov/codecov-action@0fb7174895f61a3b6b78fc075e0cd60383518dac # v5.5.5 with: files: ./packages/gooddata-sdk/coverage.xml,./packages/gooddata-pandas/coverage.xml,./packages/gooddata-fdw/coverage.xml,./packages/gooddata-flight-server/coverage.xml,./packages/gooddata-flexconnect/coverage.xml,./packages/gooddata-dbt/coverage.xml,./packages/gooddata-pipelines/coverage.xml,./packages/gooddata-eval/coverage.xml token: ${{ secrets.CODECOV_TOKEN }} @@ -33,9 +38,11 @@ jobs: if: ${{inputs.changed-python-modules == 'true'}} steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 + with: + persist-credentials: false - name: Set up python 3.14 - uses: astral-sh/setup-uv@v10.0.1 + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 with: prune-cache: true python-version: 3.14 @@ -53,9 +60,11 @@ jobs: if: ${{inputs.changed-python-modules == 'true'}} steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 + with: + persist-credentials: false - name: Set up python 3.14 - uses: astral-sh/setup-uv@v10.0.1 + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 with: prune-cache: true python-version: 3.14 @@ -70,9 +79,11 @@ jobs: if: ${{inputs.changed-python-modules == 'true'}} steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 + with: + persist-credentials: false - name: Set up python 3.14 - uses: astral-sh/setup-uv@v10.0.1 + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 with: prune-cache: true - name: Install dependencies diff --git a/.github/workflows/rw-workflow-lint.yaml b/.github/workflows/rw-workflow-lint.yaml new file mode 100644 index 000000000..0e6b5e234 --- /dev/null +++ b/.github/workflows/rw-workflow-lint.yaml @@ -0,0 +1,57 @@ +name: GitHub Actions lint Reusable workflow + +on: + workflow_call: + inputs: + changed-workflows: + type: string + default: 'false' + +permissions: {} + +jobs: + zizmor: + runs-on: + group: infra1-runners-arc + labels: runners-small + permissions: + contents: read + if: inputs.changed-workflows == 'true' + + steps: + - name: Checkout + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 + with: + persist-credentials: false + + # The version matches the zizmor hook in .pre-commit-config.yaml, so CI and the + # developers' hook audit the workflows the same way; the two should move together. + # The release asset matches the runner's architecture, and its checksum is the + # digest GitHub records for it. + - name: Install zizmor + env: + ZIZMOR_VERSION: 1.33.1 + run: | + arch=$(uname -m) + case "$arch" in + x86_64) sha256=3e6a301c7a820a2501915f5a9de8c0486da82bdec7965f068477538a98743d43 ;; + aarch64) sha256=aa487c792a7cbbe86e4f8dccd3b66de33b3b51813c090aaa0842d7ea08a3fc35 ;; + *) echo "no zizmor release for ${arch}" >&2; exit 1 ;; + esac + + archive="${RUNNER_TEMP}/zizmor.tar.gz" + curl -fsSL -o "$archive" \ + "https://github.com/zizmorcore/zizmor/releases/download/v${ZIZMOR_VERSION}/zizmor-${arch}-unknown-linux-gnu.tar.gz" + echo "${sha256} ${archive}" | sha256sum --check --strict - + mkdir -p "${RUNNER_TEMP}/zizmor" + tar -xzf "$archive" -C "${RUNNER_TEMP}/zizmor" zizmor + + echo "${RUNNER_TEMP}/zizmor" >> "$GITHUB_PATH" + "${RUNNER_TEMP}/zizmor/zizmor" --version + + # zizmor reads its configuration from .github/zizmor.yml. Informational findings, + # such as template expressions over step and job outputs, are not checked. + # zizmor's online audits look up every referenced action on GitHub and fail the run + # on a repository they cannot read, so the audit runs offline. + - name: Audit workflows + run: zizmor --offline --min-severity low --color=always . diff --git a/.github/workflows/sdk-review-relay.yml b/.github/workflows/sdk-review-relay.yml index 6dabbe656..72dd447ac 100644 --- a/.github/workflows/sdk-review-relay.yml +++ b/.github/workflows/sdk-review-relay.yml @@ -16,6 +16,9 @@ on: pull_request_review: types: [submitted] +# The dispatch authenticates with the PAT, so GITHUB_TOKEN needs no scope. +permissions: {} + jobs: relay: name: "Forward review to gdc-nas" @@ -32,15 +35,19 @@ jobs: env: GH_TOKEN: ${{ secrets.TOKEN_GITHUB_YENKINS_ADMIN }} REVIEW_BODY: ${{ github.event.review.body }} + GITHUB_EVENT_PULL_REQUEST_HEAD_REF: ${{ github.event.pull_request.head.ref }} + GITHUB_EVENT_PULL_REQUEST_USER_LOGIN: ${{ github.event.pull_request.user.login }} + GITHUB_EVENT_REVIEW_USER_LOGIN: ${{ github.event.review.user.login }} + GITHUB_EVENT_REVIEW_STATE: ${{ github.event.review.state }} run: | # Build JSON payload safely (review_body may contain quotes/newlines) jq -nc \ --arg pr_number "${{ github.event.pull_request.number }}" \ - --arg pr_branch "${{ github.event.pull_request.head.ref }}" \ - --arg pr_author "${{ github.event.pull_request.user.login }}" \ - --arg reviewer "${{ github.event.review.user.login }}" \ + --arg pr_branch "${GITHUB_EVENT_PULL_REQUEST_HEAD_REF}" \ + --arg pr_author "${GITHUB_EVENT_PULL_REQUEST_USER_LOGIN}" \ + --arg reviewer "${GITHUB_EVENT_REVIEW_USER_LOGIN}" \ --arg review_id "${{ github.event.review.id }}" \ - --arg review_state "${{ github.event.review.state }}" \ + --arg review_state "${GITHUB_EVENT_REVIEW_STATE}" \ --arg review_body "$REVIEW_BODY" \ '{ event_type: "sdk-review-submitted", @@ -59,5 +66,5 @@ jobs: echo "## Dispatched to gdc-nas" >> "$GITHUB_STEP_SUMMARY" echo "- PR: #${{ github.event.pull_request.number }}" >> "$GITHUB_STEP_SUMMARY" - echo "- Reviewer: ${{ github.event.review.user.login }}" >> "$GITHUB_STEP_SUMMARY" - echo "- State: ${{ github.event.review.state }}" >> "$GITHUB_STEP_SUMMARY" + echo "- Reviewer: ${GITHUB_EVENT_REVIEW_USER_LOGIN}" >> "$GITHUB_STEP_SUMMARY" + echo "- State: ${GITHUB_EVENT_REVIEW_STATE}" >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/sdk-slash-commands.yaml b/.github/workflows/sdk-slash-commands.yaml index 5e6a6f77f..610526777 100644 --- a/.github/workflows/sdk-slash-commands.yaml +++ b/.github/workflows/sdk-slash-commands.yaml @@ -29,7 +29,9 @@ # ============================================================================= name: SDK Slash Commands -on: +# The commenter's access is checked before anything is dispatched; see SECURITY +# above. +on: # zizmor: ignore[dangerous-triggers] issue_comment: types: [created] diff --git a/.github/workflows/staging-tests.yaml b/.github/workflows/staging-tests.yaml index a823f84ca..60d4786e7 100644 --- a/.github/workflows/staging-tests.yaml +++ b/.github/workflows/staging-tests.yaml @@ -6,7 +6,9 @@ on: branches: - master - 'rel/**' - issue_comment: + # The "Authorize comment trigger" step requires write access and an in-repository + # branch before anything is checked out. + issue_comment: # zizmor: ignore[dangerous-triggers] types: [created] workflow_dispatch: inputs: @@ -78,13 +80,13 @@ jobs: echo "sha=$(echo "$PR_DATA" | jq -r .head.sha)" >> "$GITHUB_OUTPUT" - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: ref: ${{ steps.pr.outputs.sha || github.event.pull_request.head.sha || github.sha }} persist-credentials: false - name: Set up Python - uses: astral-sh/setup-uv@v10.0.1 + uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 with: prune-cache: true python-version: '3.14' diff --git a/.github/zizmor.yml b/.github/zizmor.yml new file mode 100644 index 000000000..9db194da5 --- /dev/null +++ b/.github/zizmor.yml @@ -0,0 +1,8 @@ +# zizmor audits the workflows and actions for security issues. CI runs it from +# rw-workflow-lint.yaml and pre-commit runs it locally, both with the same arguments. +rules: + # This audit asks for the `uses: gooddata/gooddata-python-sdk/...` form for the local + # actions and reusable workflows too. The `./...` form runs the copy from the same + # commit as the calling workflow, so the calls keep it. + self-repository: + disable: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f66140447..ff2b4d0cd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,6 +35,14 @@ repos: args: [ "--update", "FILES" ] language: script types: [ text ] + - repo: https://github.com/zizmorcore/zizmor-pre-commit + rev: v1.33.1 + hooks: + - id: zizmor + # With a GitHub token in the environment, zizmor also runs its online audits, + # which fail the run on an action repository the token cannot read. The hook + # runs offline and with the same minimum severity as the CI job. + args: [ "--no-progress", "--offline", "--min-severity", "low" ] - repo: https://github.com/jorisroovers/gitlint rev: v0.19.1 hooks: diff --git a/AGENTS.md b/AGENTS.md index 7debbe62a..070050905 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -64,6 +64,7 @@ result — run the commands and read the output. | `packages//**` | the per-package sequence below, once for each package touched | | `scripts/**` or root config | `make format-fix lint-fix` from the workspace root | | `scripts/docs/**` | also `make test-docs-scripts` | +| `.github/**` | `uv run pre-commit run zizmor --all-files` — see "Workflow security" below | | `gooddata-api-client/**` | nothing — see the note below | The generated client is excluded from `make lint`, `make format` and pre-commit, and no @@ -110,9 +111,25 @@ edited. - Do not add a `# type: ignore`, a ruff `noqa`, or an entry to a `ty` allowed-unresolved list to get a step to pass. Fix the cause, or say why you cannot. -CI runs `make format`, `make lint`, `make type-check`, `make test-ci` and -`make test-docs-scripts` — the check-only variants are what gate the merge. Nothing in CI -validates commit messages; that is local only, via the commit-msg hook. +CI runs `make format`, `make lint`, `make type-check`, `make test-ci`, +`make test-docs-scripts` and, when `.github/` changes, zizmor — the check-only variants +are what gate the merge. Nothing in CI validates commit messages; that is local only, via +the commit-msg hook. + +### Workflow security — zizmor + +[zizmor] audits `.github/workflows/**` and `.github/actions/**` with the arguments the +pre-commit hook and the `rw-workflow-lint.yaml` CI job share: +`--offline --min-severity low`, configured by `.github/zizmor.yml`. Keep the zizmor version +in `.pre-commit-config.yaml` and the CI job in step. + +- Pin every third-party action to a full commit SHA with the version in a trailing comment: + `uses: actions/checkout@ # v6.1.0`. Reference this repository's own actions and + reusable workflows as `./.github/...`. +- Set `permissions: {}` at the workflow level and grant each job only the scopes it uses. +- Pass reusable workflows the secrets they need by name, never `secrets: inherit`. +- Fix a finding rather than suppress it. When the flagged pattern is required, suppress + that one line with `# zizmor: ignore[]` and a comment stating what makes it safe. ## Testing @@ -313,3 +330,4 @@ Each package's `AGENTS.md` states what it owns and, importantly, what it does no - `packages/tests-support` — shared VCR, comparison and file helpers for the test suites [vcrpy]: https://vcrpy.readthedocs.io/ +[zizmor]: https://docs.zizmor.sh/