diff --git a/.github/workflows/R-CMD-check-dev.yaml b/.github/workflows/R-CMD-check-dev.yaml index e31f491..dafb304 100644 --- a/.github/workflows/R-CMD-check-dev.yaml +++ b/.github/workflows/R-CMD-check-dev.yaml @@ -8,12 +8,13 @@ on: - "cran-*" tags: - "v*" + workflow_dispatch: name: rcc dev jobs: matrix: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} @@ -32,7 +33,7 @@ jobs: uses: ./.github/workflows/dep-matrix check-matrix: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 needs: matrix name: Check deps @@ -50,7 +51,7 @@ jobs: echo $matrix | json2yaml R-CMD-check-base: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 name: base @@ -96,7 +97,7 @@ jobs: - matrix - R-CMD-check-base - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 name: 'rcc-dev: ${{ matrix.package }}' diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index d7522af..b5bccb8 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -10,6 +10,7 @@ on: - main - master - release + - next - cran-* pull_request: branches: @@ -29,6 +30,14 @@ on: description: "Create a matrix of suggested dependencies" type: boolean default: false + run-rcc-full: + description: "Run rcc-full job" + type: boolean + default: false + run-rcc-suggests: + description: "Run rcc-suggests job" + type: boolean + default: false merge_group: types: - checks_requested @@ -67,17 +76,16 @@ jobs: ref: ${{ inputs.ref }} - name: Update status for rcc + if: github.actor != 'Copilot' # FIXME: Wrap into action - if: github.event_name == 'workflow_dispatch' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + echo "Actor: ${{ github.actor }}" + # Check status of this workflow state="pending" sha=${{ inputs.ref }} - if [ -z "${sha}" ]; then - sha=${{ github.head_ref }} - fi if [ -z "${sha}" ]; then sha=${{ github.sha }} fi @@ -174,7 +182,7 @@ jobs: - name: Update status for rcc # FIXME: Wrap into action - if: always() && github.event_name == 'workflow_dispatch' + if: always() && (github.actor != 'Copilot') env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -190,12 +198,42 @@ jobs: sha=${{ inputs.ref }} fi if [ -z "${sha}" ]; then - sha=${{ github.head_ref }} + sha=${{ github.sha }} + fi + sha=$(git rev-parse ${sha}) + + html_url=$(gh api \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + repos/${{ github.repository }}/actions/runs/${{ github.run_id }} | jq -r .html_url) + + description="${{ github.workflow }} / ${{ github.job }}" + + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + repos/${{ github.repository }}/statuses/${sha} \ + -f "state=${state}" -f "target_url=${html_url}" -f "description=${description}" -f "context=rcc" + shell: bash + + - name: Update status for rcc (Copilot) + # Update status directly when triggered by Copilot or bots, since they can't dispatch workflows + if: always() && (github.actor == 'Copilot') + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Set status to success if job succeeded, failure otherwise + if [ "${{ job.status }}" == "success" ]; then + state="success" + else + state="failure" fi + sha=${{ inputs.ref }} if [ -z "${sha}" ]; then sha=${{ github.sha }} fi - sha=$(git rev-parse ${sha}) + sha=$(git rev-parse ${sha}) html_url=$(gh api \ -H "Accept: application/vnd.github+json" \ @@ -239,7 +277,7 @@ jobs: runs-on: ${{ matrix.os }} - if: ${{ needs.rcc-smoke.outputs.versions-matrix != '' }} + if: ${{ needs.rcc-smoke.outputs.versions-matrix != '' && (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.run-rcc-full)) }} name: 'rcc: ${{ matrix.os }} (${{ matrix.r }}) ${{ matrix.desc }}' @@ -301,7 +339,7 @@ jobs: runs-on: ubuntu-22.04 - if: ${{ needs.rcc-smoke.outputs.dep-suggests-matrix != '' }} + if: ${{ needs.rcc-smoke.outputs.dep-suggests-matrix != '' && (github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.run-rcc-suggests)) }} name: Without ${{ matrix.package }} diff --git a/.github/workflows/commit/action.yml b/.github/workflows/commit/action.yml index 8dd0c9e..e385cd8 100644 --- a/.github/workflows/commit/action.yml +++ b/.github/workflows/commit/action.yml @@ -32,7 +32,7 @@ runs: protected=${{ github.ref_protected }} foreign=${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }} is_pr=${{ github.event_name == 'pull_request' }} - if [ "${is_pr}" = "true" ]; then + if [ "${is_pr}" = "true" ] && [ "${foreign}" = "true" ]; then # Running on a PR - will use reviewdog in next step echo "Code changes detected on PR, will suggest changes via reviewdog" echo "use_reviewdog=true" | tee -a $GITHUB_OUTPUT diff --git a/.github/workflows/copilot-setup-steps.yaml b/.github/workflows/copilot-setup-steps.yaml new file mode 100644 index 0000000..766b03a --- /dev/null +++ b/.github/workflows/copilot-setup-steps.yaml @@ -0,0 +1,51 @@ +name: "Copilot Setup Steps" + +# Automatically run the setup steps when they are changed to allow for easy validation, and +# allow manual testing through the repository's "Actions" tab +on: + workflow_dispatch: + push: + paths: + - .github/workflows/copilot-setup-steps.yml + pull_request: + paths: + - .github/workflows/copilot-setup-steps.yml + +jobs: + # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. + copilot-setup-steps: + runs-on: ubuntu-latest + + # Set the permissions to the lowest permissions possible needed for your steps. + # Copilot will be given its own token for its operations. + permissions: + # If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete. + contents: read + + # You can define any steps you want, and they will run before the agent starts. + # If you do not check out your code, Copilot will do this for you. + steps: + - name: Checkout code + uses: actions/checkout@v5 + - uses: ./.github/workflows/custom/before-install + if: hashFiles('.github/workflows/custom/before-install/action.yml') != '' + + - uses: ./.github/workflows/install + with: + token: ${{ secrets.GITHUB_TOKEN }} + cache-version: copilot + needs: build, check, website + # Beware of using dev pkgdown here, has brought in dev dependencies in the past + extra-packages: any::rcmdcheck r-lib/roxygen2 any::decor r-lib/styler r-lib/pkgdown deps::. + + - uses: ./.github/workflows/custom/after-install + if: hashFiles('.github/workflows/custom/after-install/action.yml') != '' + + # Must come after the custom after-install workflow + - name: Install package + run: | + UserNM=true R CMD INSTALL . || true + shell: bash + + - name: Install air + uses: posit-dev/setup-air@v1 diff --git a/.github/workflows/install/action.yml b/.github/workflows/install/action.yml index d825d90..a0aec0c 100644 --- a/.github/workflows/install/action.yml +++ b/.github/workflows/install/action.yml @@ -111,7 +111,7 @@ runs: pak-version: stable needs: ${{ inputs.needs }} packages: ${{ inputs.packages }} - extra-packages: ${{ inputs.extra-packages }} ${{ ( matrix.covr && 'r-lib/covr#611 xml2' ) || '' }} ${{ steps.get-extra.outputs.packages }} + extra-packages: ${{ inputs.extra-packages }} ${{ ( matrix.covr && 'r-lib/covr xml2' ) || '' }} ${{ steps.get-extra.outputs.packages }} cache-version: ${{ inputs.cache-version }} - name: Add pkg.lock to .gitignore diff --git a/.github/workflows/update-snapshots/action.yml b/.github/workflows/update-snapshots/action.yml index 03d2173..6a54cb0 100644 --- a/.github/workflows/update-snapshots/action.yml +++ b/.github/workflows/update-snapshots/action.yml @@ -24,9 +24,10 @@ runs: pattern <- paste0(patterns, collapse = "|") tryCatch( { - result <- as.data.frame(testthat::test_local(pattern = pattern, reporter = "silent", stop_on_failure = FALSE)) - print(result) + Sys.setenv(TESTTHAT_PARALLEL = FALSE) + result <- as.data.frame(testthat::test_local(pattern = pattern, reporter = "location", stop_on_failure = FALSE)) failures <- result[result$failed + result$warning > 0, ] + print(failures) if (nrow(failures) > 0) { writeLines("Snapshot tests failed/warned.") print(failures[names(failures) != "result"])