diff --git a/.github/workflows/audit.yaml b/.github/workflows/audit.yaml index b9882d8c..ef941db3 100644 --- a/.github/workflows/audit.yaml +++ b/.github/workflows/audit.yaml @@ -33,11 +33,45 @@ jobs: image: ghcr.io/insightsengineering/rstudio:latest name: oysteR scan πŸ¦ͺ if: > - !contains(github.event.commits[0].message, '[skip audit]') - && github.event.pull_request.draft == false + github.event.pull_request.draft == false steps: + - name: Get branch names 🌿 + id: branch-name + uses: tj-actions/branch-names@v7 + + - name: Checkout repo (PR) πŸ›Ž + uses: actions/checkout@v4 + if: github.event_name == 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + fetch-depth: 1 + - name: Checkout repo πŸ›Ž uses: actions/checkout@v4 + if: github.event_name != 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + fetch-depth: 1 + + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + fi + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip audit]" - name: Normalize inputs πŸ› οΈ id: normalizer diff --git a/.github/workflows/bioccheck.yaml b/.github/workflows/bioccheck.yaml index cf5408fd..7607a932 100644 --- a/.github/workflows/bioccheck.yaml +++ b/.github/workflows/bioccheck.yaml @@ -69,8 +69,7 @@ jobs: name: ${{ matrix.config.image }}, version ${{ matrix.config.tag }} runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip bioccheck]') - && contains(inputs.enable-bioccheck, 'true') + contains(inputs.enable-bioccheck, 'true') && github.event.pull_request.draft == false container: image: ${{ matrix.config.image }}:${{ matrix.config.tag }} @@ -107,6 +106,25 @@ jobs: ref: ${{ steps.branch-name.outputs.head_ref_branch }} path: ${{ github.event.repository.name }} + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + fi + shell: bash + env: + GH_TOKEN: ${{ steps.github-token.outputs.token }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip bioccheck]" + - name: Restore SD cache πŸ’° uses: actions/cache@v4 with: diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 55b2f958..86e80eee 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -184,8 +184,7 @@ jobs: name: ${{ matrix.config.image }}, version ${{ matrix.config.tag }} runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip r-cmd]') - && github.event.pull_request.draft == false + github.event.pull_request.draft == false container: image: ${{ matrix.config.image }}:${{ matrix.config.tag }} outputs: @@ -212,6 +211,51 @@ jobs: id: branch-name uses: tj-actions/branch-names@v7 + - name: Checkout repo (PR) πŸ›Ž + uses: actions/checkout@v4 + if: github.event_name == 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + path: ${{ github.event.repository.name }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + # When fetch-depth is set to 1 (default), and if additional commits are added + # to the branch between this step and the 'Set TESTING_DEPTH' step, git might fail + # referencing ${{ github.event.after }} commit + # because it's not the latest commit fetched by this step. + fetch-depth: 0 + + - name: Checkout repo πŸ›Ž + uses: actions/checkout@v4 + if: github.event_name != 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + path: ${{ github.event.repository.name }} + + # - name: Check commit message πŸ’¬ + # run: | + # git config --global --add safe.directory $(pwd) + # export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + # echo "head_commit_message = $head_commit_message" + # if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + # echo "Skip instruction detected - cancelling the workflow." + # curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + # tar -xzf gh.tar.gz --strip-components 2 + # ./gh version + # ./gh run cancel ${{ github.run_id }} + # ./gh run watch ${{ github.run_id }} + # fi + # shell: bash + # env: + # GH_TOKEN: ${{ steps.github-token.outputs.token }} + # GH_CLI_VERSION: 2.44.1 + # SKIP_INSTRUCTION: "[skip r-cmd]" + + - name: Check commit message πŸ’¬ + uses: ./check-commit-message + with: + gh-token: ${{ steps.github-token.outputs.token }} + skip-instruction: "[skip r-cmd]" + - name: Checkout gh-pages πŸ›Ž if: >- inputs.publish-unit-test-report-gh-pages == true @@ -295,26 +339,6 @@ jobs: run: npm i -g xunit-viewer shell: bash - - name: Checkout repo (PR) πŸ›Ž - uses: actions/checkout@v4 - if: github.event_name == 'pull_request' - with: - ref: ${{ steps.branch-name.outputs.head_ref_branch }} - path: ${{ github.event.repository.name }} - repository: ${{ github.event.pull_request.head.repo.full_name }} - # When fetch-depth is set to 1 (default), and if additional commits are added - # to the branch between this step and the 'Set TESTING_DEPTH' step, git might fail - # referencing ${{ github.event.after }} commit - # because it's not the latest commit fetched by this step. - fetch-depth: 0 - - - name: Checkout repo πŸ›Ž - uses: actions/checkout@v4 - if: github.event_name != 'pull_request' - with: - ref: ${{ steps.branch-name.outputs.head_ref_branch }} - path: ${{ github.event.repository.name }} - - name: Restore SD cache πŸ’° if: inputs.install-deps-from-package-repositories == '' uses: actions/cache@v4 diff --git a/.github/workflows/check-commit-message/action.yml b/.github/workflows/check-commit-message/action.yml new file mode 100644 index 00000000..b3f85cb8 --- /dev/null +++ b/.github/workflows/check-commit-message/action.yml @@ -0,0 +1,38 @@ +name: 'Check commit message' +inputs: + gh-cli-version: + description: 'GitHub CLI version' + required: true + default: '2.44.1' + skip-instruction: + description: 'Skip instruction' + required: true + default: '' + github-token: + description: 'GitHub token' + required: true + default: '' +runs: + using: "composite" + steps: + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." + fi + shell: bash + env: + GH_TOKEN: ${{ inputs.github-token }} + GH_CLI_VERSION: ${{ inputs.gh-cli-version }} + SKIP_INSTRUCTION: ${{ inputs.skip-instruction }} + diff --git a/.github/workflows/gitleaks.yaml b/.github/workflows/gitleaks.yaml index 7b791fe0..c33dc673 100644 --- a/.github/workflows/gitleaks.yaml +++ b/.github/workflows/gitleaks.yaml @@ -36,11 +36,44 @@ jobs: name: gitleaks πŸ’§ runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip gitleaks]') - && github.event.pull_request.draft == false + github.event.pull_request.draft == false + steps: + - name: Get branch names 🌿 + id: branch-name + uses: tj-actions/branch-names@v7 + + - name: Checkout repo (PR) πŸ›Ž + uses: actions/checkout@v4 + if: github.event_name == 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - name: Checkout repo πŸ›Ž uses: actions/checkout@v4 + if: github.event_name != 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + fi + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip gitleaks]" - name: Download and install gitleaks πŸ’§ run: | @@ -65,15 +98,48 @@ jobs: name: PII Check πŸ’³ runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip pii-check]') - && github.event.pull_request.draft == false + github.event.pull_request.draft == false && inputs.check-for-pii == true + steps: + - name: Get branch names 🌿 + id: branch-name + uses: tj-actions/branch-names@v7 + + - name: Checkout repo (PR) πŸ›Ž + uses: actions/checkout@v4 + if: github.event_name == 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + fetch-depth: 0 + - name: Checkout repo πŸ›Ž uses: actions/checkout@v4 + if: github.event_name != 'pull_request' with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} fetch-depth: 0 + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + fi + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip pii-check]" + - name: Run Presidio to check for PII β˜” uses: insightsengineering/presidio-action@v1 with: diff --git a/.github/workflows/licenses.yaml b/.github/workflows/licenses.yaml index 4daa53ea..a62f1674 100644 --- a/.github/workflows/licenses.yaml +++ b/.github/workflows/licenses.yaml @@ -30,11 +30,44 @@ jobs: runs-on: ubuntu-latest name: Check 🚩 if: > - !contains(github.event.commits[0].message, '[skip licenses]') - && github.event.pull_request.draft == false + github.event.pull_request.draft == false + steps: + - name: Get branch names 🌿 + id: branch-name + uses: tj-actions/branch-names@v7 + + - name: Checkout repo (PR) πŸ›Ž + uses: actions/checkout@v4 + if: github.event_name == 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - name: Checkout repo πŸ›Ž uses: actions/checkout@v4 + if: github.event_name != 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + fi + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip licenses]" - name: Generate license report πŸ“œ uses: insightsengineering/r-license-report@v1 diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index 44bf8696..4c9913c7 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -15,6 +15,11 @@ on: - main workflow_dispatch: workflow_call: + secrets: + REPO_GITHUB_TOKEN: + description: | + Github token with read access and write access to repositories. + required: false inputs: lintr_error_on_lint: description: Produce an error when lints are found @@ -36,14 +41,47 @@ jobs: name: SuperLinter πŸ¦Έβ€β™‚οΈ runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip linter]') - && github.event.pull_request.draft == false + github.event.pull_request.draft == false + steps: + - name: Get branch names 🌿 + id: branch-name + uses: tj-actions/branch-names@v7 + + - name: Checkout repo (PR) πŸ›Ž + uses: actions/checkout@v4 + if: github.event_name == 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + fetch-depth: 0 + - name: Checkout repo πŸ›Ž uses: actions/checkout@v4 + if: github.event_name != 'pull_request' with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} fetch-depth: 0 + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + fi + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip linter]" + - name: Override SuperLinter configs πŸ’Ύ run: | # Override markdownlint default config @@ -86,16 +124,43 @@ jobs: name: Lint R code 🧢 runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip linter]') - && github.event.pull_request.draft == false + github.event.pull_request.draft == false container: image: ghcr.io/insightsengineering/rstudio:latest + steps: + - name: Checkout repo (PR) πŸ›Ž + uses: actions/checkout@v4 + if: github.event_name == 'pull_request' + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + - name: Checkout repo πŸ›Ž uses: actions/checkout@v4 + if: github.event_name != 'pull_request' with: fetch-depth: 0 + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + fi + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip linter]" + - name: Changed files πŸ–‹οΈ id: files uses: Ana06/get-changed-files@v2.2.0 diff --git a/.github/workflows/roxygen.yaml b/.github/workflows/roxygen.yaml index 92947fae..a3e2c07f 100644 --- a/.github/workflows/roxygen.yaml +++ b/.github/workflows/roxygen.yaml @@ -56,8 +56,7 @@ jobs: name: Manual pages check 🏁 runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip roxygen]') - && github.event.pull_request.draft == false + github.event.pull_request.draft == false container: image: ghcr.io/insightsengineering/rstudio:latest @@ -94,6 +93,25 @@ jobs: ref: ${{ steps.branch-name.outputs.head_ref_branch }} path: ${{ github.event.repository.name }} + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + fi + shell: bash + env: + GH_TOKEN: ${{ steps.github-token.outputs.token }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip roxygen]" + - name: Restore SD cache πŸ’° uses: actions/cache@v4 with: diff --git a/.github/workflows/spelling.yaml b/.github/workflows/spelling.yaml index a0555f4d..efd7fc1b 100644 --- a/.github/workflows/spelling.yaml +++ b/.github/workflows/spelling.yaml @@ -57,18 +57,24 @@ jobs: fi shell: bash - - name: Checkout Code πŸ›Ž + - name: Get branch names 🌿 + id: branch-name + uses: tj-actions/branch-names@v7 + + - name: Checkout repo (PR) πŸ›Ž uses: actions/checkout@v4 - if: github.event_name != 'push' + if: github.event_name == 'pull_request' with: - token: ${{ steps.github-token.outputs.token }} + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + repository: ${{ github.event.pull_request.head.repo.full_name }} fetch-depth: 1 - ref: ${{ github.event.pull_request.head.sha }} + token: ${{ steps.github-token.outputs.token }} - - name: Checkout Code πŸ›Ž + - name: Checkout repo πŸ›Ž uses: actions/checkout@v4 - if: github.event_name == 'push' + if: github.event_name != 'pull_request' with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} token: ${{ steps.github-token.outputs.token }} - name: Check commit message πŸ’¬ diff --git a/.github/workflows/style.yaml b/.github/workflows/style.yaml index ab094d1d..b5bf427d 100644 --- a/.github/workflows/style.yaml +++ b/.github/workflows/style.yaml @@ -41,8 +41,7 @@ jobs: name: Check code style πŸ”  runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip style]') - && github.event.pull_request.draft == false + github.event.pull_request.draft == false container: image: ghcr.io/insightsengineering/rstudio:latest @@ -60,17 +59,45 @@ jobs: shell: bash - name: Get branch names 🌿 - if: inputs.auto-update id: branch-name uses: tj-actions/branch-names@v7 - - name: Checkout Code πŸ›Ž + - name: Checkout repo (PR) πŸ›Ž uses: actions/checkout@v4 + if: github.event_name == 'pull_request' with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} path: ${{ github.event.repository.name }} + repository: ${{ github.event.pull_request.head.repo.full_name }} fetch-depth: 0 token: ${{ steps.github-token.outputs.token }} + + - name: Checkout repo πŸ›Ž + uses: actions/checkout@v4 + if: github.event_name != 'pull_request' + with: ref: ${{ steps.branch-name.outputs.head_ref_branch }} + path: ${{ github.event.repository.name }} + token: ${{ steps.github-token.outputs.token }} + + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + fi + shell: bash + env: + GH_TOKEN: ${{ steps.github-token.outputs.token }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip style]" - name: Install styler πŸ‘š run: | diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index e97d0995..25386378 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -98,8 +98,7 @@ jobs: name: Coverage πŸ“” runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip coverage]') - && github.event.pull_request.draft == false + github.event.pull_request.draft == false container: image: ghcr.io/insightsengineering/rstudio:latest outputs: @@ -108,6 +107,7 @@ jobs: is-latest-tag: ${{ steps.current-branch-or-tag.outputs.is-latest-tag }} is-rc-tag: ${{ steps.current-branch-or-tag.outputs.is-rc-tag }} multiversion-docs: ${{ steps.current-branch-or-tag.outputs.multiversion-docs }} + steps: - name: Setup token πŸ”‘ id: github-token @@ -180,6 +180,25 @@ jobs: ref: ${{ steps.branch-name.outputs.head_ref_branch }} path: ${{ github.event.repository.name }} + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + fi + shell: bash + env: + GH_TOKEN: ${{ steps.github-token.outputs.token }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip coverage]" + - name: Normalize inputs ⊳ id: normalizer shell: bash @@ -306,22 +325,50 @@ jobs: name: Covtracer πŸ„ runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip coverage]') - && github.event.pull_request.draft == false + github.event.pull_request.draft == false && contains(inputs.enable-covtracer, 'true') container: image: ghcr.io/insightsengineering/rstudio:latest + steps: - name: Get branch names 🌿 id: branch-name uses: tj-actions/branch-names@v7 + - name: Checkout repo (PR) πŸ›Ž + uses: actions/checkout@v4 + if: github.event_name == 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + path: ${{ github.event.repository.name }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - name: Checkout repo πŸ›Ž uses: actions/checkout@v4 + if: github.event_name != 'pull_request' with: ref: ${{ steps.branch-name.outputs.head_ref_branch }} path: ${{ github.event.repository.name }} + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + fi + shell: bash + env: + GH_TOKEN: ${{ steps.github-token.outputs.token }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip coverage]" + - name: Restore SD cache πŸ’° uses: actions/cache@v4 with: diff --git a/.github/workflows/validation.yaml b/.github/workflows/validation.yaml index 872b163a..c853ed11 100644 --- a/.github/workflows/validation.yaml +++ b/.github/workflows/validation.yaml @@ -53,8 +53,7 @@ jobs: name: Create report πŸ“ƒ runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip validation]') - && github.event.pull_request.draft == false + github.event.pull_request.draft == false container: image: ghcr.io/insightsengineering/rstudio:latest permissions: @@ -74,8 +73,41 @@ jobs: fi shell: bash + - name: Get branch names 🌿 + id: branch-name + uses: tj-actions/branch-names@v7 + + - name: Checkout repo (PR) πŸ›Ž + uses: actions/checkout@v4 + if: github.event_name == 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - name: Checkout repo πŸ›Ž uses: actions/checkout@v4 + if: github.event_name != 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + fi + shell: bash + env: + GH_TOKEN: ${{ steps.github-token.outputs.token }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip validation]" - name: Normalize variables πŸ“ run: | diff --git a/.github/workflows/verdepcheck.yaml b/.github/workflows/verdepcheck.yaml index b7102f9d..660f6199 100644 --- a/.github/workflows/verdepcheck.yaml +++ b/.github/workflows/verdepcheck.yaml @@ -44,8 +44,7 @@ jobs: name: Dependency Test πŸ”’ runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip dependency-test]') - && github.event.pull_request.draft == false + github.event.pull_request.draft == false container: image: ghcr.io/insightsengineering/rstudio:latest @@ -62,8 +61,34 @@ jobs: fi shell: bash - - name: Checkout Code πŸ›Ž + - name: Get branch names 🌿 + id: branch-name + uses: tj-actions/branch-names@v7 + + - name: Checkout repo πŸ›Ž uses: actions/checkout@v4 + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + fetch-depth: 1 + + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + fi + shell: bash + env: + GH_TOKEN: ${{ steps.github-token.outputs.token }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip dependency-test]" - name: Normalize variables πŸ“ run: | diff --git a/.github/workflows/version-bump.yaml b/.github/workflows/version-bump.yaml index 1a8be349..05c8654b 100644 --- a/.github/workflows/version-bump.yaml +++ b/.github/workflows/version-bump.yaml @@ -36,10 +36,6 @@ jobs: vbump: name: Bump version ‴ runs-on: ubuntu-latest - if: | - !(contains(github.event.commits[0].message, '[skip vbump]') || - contains(github.event.head_commit.message, '[skip vbump]') - ) container: image: docker.io/rocker/tidyverse:latest @@ -56,11 +52,35 @@ jobs: fi shell: bash + - name: Get branch names 🌿 + id: branch-name + uses: tj-actions/branch-names@v7 + - name: Checkout repo πŸ›Ž uses: actions/checkout@v4 with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} token: ${{ steps.github-token.outputs.token }} + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + fi + shell: bash + env: + GH_TOKEN: ${{ steps.github-token.outputs.token }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip vbump]" + - name: Bump version in DESCRIPTION πŸ“œ if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || inputs.vbump-after-release == true }} run: desc::desc_bump_version("dev", normalize = TRUE) diff --git a/.github/workflows/version.yaml b/.github/workflows/version.yaml index 2ea74f72..86ae56bb 100644 --- a/.github/workflows/version.yaml +++ b/.github/workflows/version.yaml @@ -31,11 +31,44 @@ jobs: name: Version check 🏁 runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip version]') - && github.event.pull_request.draft == false + github.event.pull_request.draft == false + steps: + - name: Get branch names 🌿 + id: branch-name + uses: tj-actions/branch-names@v7 + + - name: Checkout repo (PR) πŸ›Ž + uses: actions/checkout@v4 + if: github.event_name == 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - name: Checkout repo πŸ›Ž uses: actions/checkout@v4 + if: github.event_name != 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + fi + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip version]" - name: NEWS.md and DESCRIPTION Version check 🏁 run: | @@ -67,11 +100,43 @@ jobs: name: Emoji in NEWS.md πŸ“° runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip version]') - && github.event.pull_request.draft == false + github.event.pull_request.draft == false steps: + - name: Get branch names 🌿 + id: branch-name + uses: tj-actions/branch-names@v7 + + - name: Checkout repo (PR) πŸ›Ž + uses: actions/checkout@v4 + if: github.event_name == 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - name: Checkout repo πŸ›Ž uses: actions/checkout@v4 + if: github.event_name != 'pull_request' + with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} + + - name: Check commit message πŸ’¬ + run: | + git config --global --add safe.directory $(pwd) + export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')" + echo "head_commit_message = $head_commit_message" + if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then + echo "Skip instruction detected - cancelling the workflow." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + fi + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip version]" - name: Set up Python 🐍 uses: actions/setup-python@v5