Skip to content

Commit

Permalink
Run checks on update_datasets change, but report success early. (#41)
Browse files Browse the repository at this point in the history
* Run checks on update_datasets change, but report success early.

* Get more history.

* Combine jobs.

* Remove dependency on non-existant step.

* Combine jobs for other workflows.

* Explicitly run on bash.
  • Loading branch information
jonthegeek authored Dec 9, 2024
1 parent ee2abfd commit b09e100
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 19 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
on:
push:
branches: [main]
paths-ignore:
- .github/workflows/update_datasets.yaml
pull_request:
branches: [main]
paths-ignore:
- .github/workflows/update_datasets.yaml

name: R-CMD-check

Expand All @@ -34,20 +30,40 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # Ensure at least one commit history is fetched

- name: Check if only workflow file has changed
id: file-check
shell: bash
run: |
if git diff --name-only HEAD^ HEAD | grep -v -e '^.github/workflows/update_datasets.yaml$'; then
echo "other-files-changed=true" >> $GITHUB_ENV
else
echo "other-files-changed=false" >> $GITHUB_ENV
fi
- name: Skip workflow if only workflow file has changed
if: env.other-files-changed == 'false'
run: echo "Only workflow file has changed. Reporting success."

- uses: r-lib/actions/setup-pandoc@v2
if: env.other-files-changed == 'true'

- uses: r-lib/actions/setup-r@v2
if: env.other-files-changed == 'true'
with:
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
if: env.other-files-changed == 'true'
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
if: env.other-files-changed == 'true'
with:
upload-snapshots: true
34 changes: 26 additions & 8 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
on:
push:
branches: [main]
paths-ignore:
- .github/workflows/update_datasets.yaml
pull_request:
branches: [main]
paths-ignore:
- .github/workflows/update_datasets.yaml
release:
types: [published]
workflow_dispatch:
Expand All @@ -27,24 +23,46 @@ jobs:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # Ensure at least one commit history is fetched

- name: Check if only workflow file has changed
id: file-check
run: |
if git diff --name-only HEAD^ HEAD | grep -v -e '^.github/workflows/update_datasets.yaml$'; then
echo "other-files-changed=true" >> $GITHUB_ENV
else
echo "other-files-changed=false" >> $GITHUB_ENV
fi
- name: Skip workflow if only workflow file has changed
if: env.other-files-changed == 'false'
run: echo "Only workflow file has changed. Reporting success."

- uses: r-lib/actions/setup-pandoc@v2
- name: Setup Pandoc
if: env.other-files-changed == 'true'
uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
- name: Setup R
if: env.other-files-changed == 'true'
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
- name: Setup R dependencies
if: env.other-files-changed == 'true'
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
if: env.other-files-changed == 'true'
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
if: env.other-files-changed == 'true' && github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
clean: false
Expand Down
30 changes: 23 additions & 7 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
on:
push:
branches: [main]
paths-ignore:
- .github/workflows/update_datasets.yaml
pull_request:
branches: [main]
paths-ignore:
- .github/workflows/update_datasets.yaml
workflow_dispatch:

name: test-coverage
Expand All @@ -18,20 +14,40 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # Ensure at least one commit history is fetched

- name: Check if only workflow file has changed
id: file-check
run: |
if git diff --name-only HEAD^ HEAD | grep -v -e '^.github/workflows/update_datasets.yaml$'; then
echo "other-files-changed=true" >> $GITHUB_ENV
else
echo "other-files-changed=false" >> $GITHUB_ENV
fi
- name: Skip workflow if only workflow file has changed
if: env.other-files-changed == 'false'
run: echo "Only workflow file has changed. Reporting success."

- uses: actions/checkout@v4
if: env.other-files-changed == 'true'

- uses: r-lib/actions/setup-r@v2
if: env.other-files-changed == 'true'
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
if: env.other-files-changed == 'true'
with:
extra-packages: any::covr
needs: coverage

- name: Test coverage
if: env.other-files-changed == 'true'
run: |
covr::codecov(
quiet = FALSE,
Expand All @@ -41,14 +57,14 @@ jobs:
shell: Rscript {0}

- name: Show testthat output
if: always()
if: always() && env.other-files-changed == 'true'
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
if: failure() && env.other-files-changed == 'true'
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
Expand Down

0 comments on commit b09e100

Please sign in to comment.