diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 68651f0..3f1cc98 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -24,25 +24,17 @@ jobs: - {os: ubuntu-latest, r: 'release'} - {os: ubuntu-latest, r: 'oldrel-1'} - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - R_KEEP_PKG_SOURCE: yes - steps: - uses: actions/checkout@v6 - - uses: r-lib/actions/setup-pandoc@v2 - - - uses: r-lib/actions/setup-r@v2 + - uses: ./.github/workflows/install with: + token: ${{ secrets.GITHUB_TOKEN }} r-version: ${{ matrix.config.r }} http-user-agent: ${{ matrix.config.http-user-agent }} - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::rcmdcheck needs: check + extra-packages: any::rcmdcheck + cache-version: "1" - uses: r-lib/actions/check-r-package@v2 with: diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml new file mode 100644 index 0000000..f22d113 --- /dev/null +++ b/.github/workflows/copilot-setup-steps.yml @@ -0,0 +1,34 @@ +name: "Copilot Setup Steps" + +# Automatically run when the file changes 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 + + # Lowest permissions needed; Copilot gets its own token for its operations. + permissions: + contents: read + + steps: + - uses: actions/checkout@v6 + + - uses: ./.github/workflows/install + with: + token: ${{ secrets.GITHUB_TOKEN }} + cache-version: copilot + needs: build, check, website + extra-packages: any::rcmdcheck any::roxygen2 any::pkgdown local::. + + - name: Install air + uses: posit-dev/setup-air@v1 diff --git a/.github/workflows/install/action.yml b/.github/workflows/install/action.yml new file mode 100644 index 0000000..95c460b --- /dev/null +++ b/.github/workflows/install/action.yml @@ -0,0 +1,45 @@ +name: "Install R and dependencies" +description: "Set up pandoc, R, and package dependencies" +inputs: + token: + description: "GitHub token, set to secrets.GITHUB_TOKEN" + required: true + r-version: + description: "R version, passed to r-lib/actions/setup-r@v2" + required: false + default: release + http-user-agent: + description: "HTTP user agent, passed to r-lib/actions/setup-r@v2" + required: false + default: "" + needs: + description: "Config/Needs tag(s), passed to r-lib/actions/setup-r-dependencies@v2" + required: false + default: "" + extra-packages: + description: "Extra packages, passed to r-lib/actions/setup-r-dependencies@v2" + required: false + default: any::rcmdcheck + cache-version: + description: "Cache version for r-lib/actions/setup-r-dependencies@v2" + required: false + default: "1" + +runs: + using: "composite" + steps: + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ inputs.r-version }} + http-user-agent: ${{ inputs.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + env: + GITHUB_PAT: ${{ inputs.token }} + with: + needs: ${{ inputs.needs }} + extra-packages: ${{ inputs.extra-packages }} + cache-version: ${{ inputs.cache-version }} diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 88044f4..bda4e98 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -17,23 +17,17 @@ jobs: # Only restrict concurrency for non-PR jobs concurrency: group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} permissions: contents: write steps: - uses: actions/checkout@v6 - - uses: r-lib/actions/setup-pandoc@v2 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 + - uses: ./.github/workflows/install with: - extra-packages: any::pkgdown, local::. + token: ${{ secrets.GITHUB_TOKEN }} needs: website + extra-packages: any::pkgdown local::. + cache-version: "1" - name: Build site run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml index 5edb318..e97776b 100644 --- a/.github/workflows/pr-commands.yaml +++ b/.github/workflows/pr-commands.yaml @@ -11,8 +11,6 @@ jobs: if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }} name: document runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v6 @@ -20,14 +18,12 @@ jobs: with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 + - uses: ./.github/workflows/install with: - extra-packages: any::roxygen2 + token: ${{ secrets.GITHUB_TOKEN }} needs: pr-document + extra-packages: any::roxygen2 + cache-version: "1" - name: Document run: roxygen2::roxygenise() @@ -48,8 +44,6 @@ jobs: if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }} name: style runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v6 @@ -59,13 +53,12 @@ jobs: - uses: r-lib/actions/setup-r@v2 - - name: Install dependencies - run: install.packages("styler") - shell: Rscript {0} + - name: Install air + uses: posit-dev/setup-air@v1 - name: Style - run: styler::style_pkg() - shell: Rscript {0} + run: air format . + shell: bash - name: commit run: | diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index e717d78..2ef4dbf 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -11,35 +11,41 @@ name: test-coverage jobs: test-coverage: runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - steps: - uses: actions/checkout@v6 - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 + - uses: ./.github/workflows/install with: - extra-packages: any::covr + token: ${{ secrets.GITHUB_TOKEN }} needs: coverage + extra-packages: any::covr + cache-version: "1" - name: Test coverage run: | - covr::codecov( + cov <- covr::package_coverage( quiet = FALSE, clean = FALSE, - install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package") + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") ) + print(cov) + covr::to_cobertura(cov) shell: Rscript {0} + - uses: codecov/codecov-action@v5 + with: + # Fail if error if not on PR, or if on PR and token is given + fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }} + files: ./cobertura.xml + plugins: noop + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + - name: Show testthat output if: always() run: | ## -------------------------------------------------------------------- - find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true + find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true shell: bash - name: Upload test results