Skip to content

Commit 237a559

Browse files
committed
Replace styler with air
https://posit-dev.github.io/air/formatter.html https://www.tidyverse.org/blog/2025/02/air/ https://yohann-data.fr/posts/airformatter/ Update phs_style_and_document.yaml Split the style and document actions Remove automatic documentation job from workflow Removed the phs_document job for automatic documentation generation and its dependencies. Update phs_package_checks.yaml Update phs_style.yaml to add default air.toml Update phs_style.yaml Update phs_document.yaml Update phs_document.yaml Update phs_style.yaml Update phs_style.yaml Update phs_document.yaml Update phs_package_checks.yaml
1 parent c4dad50 commit 237a559

File tree

4 files changed

+162
-140
lines changed

4 files changed

+162
-140
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
workflow_call:
5+
6+
name: phs_document.yaml
7+
8+
permissions:
9+
contents: read
10+
pull-requests: read
11+
12+
jobs:
13+
phs_document:
14+
name: "Automatically re-build the package documentation"
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
env:
20+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
21+
steps:
22+
- name: Checkout repo
23+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
24+
with:
25+
fetch-depth: 0
26+
ref: ${{ github.event.pull_request.head.sha }}
27+
28+
- name: Setup R
29+
uses: r-lib/actions/setup-r@bd49c52ffe281809afa6f0fecbf37483c5dd0b93 # v2.11.3
30+
with:
31+
use-public-rspm: true
32+
33+
- name: Install dependencies
34+
uses: r-lib/actions/setup-r-dependencies@bd49c52ffe281809afa6f0fecbf37483c5dd0b93 # v2.11.3
35+
with:
36+
extra-packages: |
37+
any::roxygen2
38+
any::desc
39+
needs: |
40+
website
41+
coverage
42+
43+
- name: Normalise DESCRIPTION
44+
run: desc::desc_normalize()
45+
shell: Rscript {0}
46+
47+
- name: Document
48+
run: roxygen2::roxygenise()
49+
shell: Rscript {0}
50+
51+
- name: Commit and push changes
52+
id: commit_step_document
53+
uses: stefanzweifel/git-auto-commit-action@28e16e81777b558cc906c8750092100bbb34c5e3 # v7.0.0
54+
with:
55+
commit_message: "Document package (GHA)"
56+
continue-on-error: true
57+
58+
- name: Create Pull Request
59+
if: ${{ steps.commit_step_document.outputs.changes_detected == 'true' && steps.commit_step_document.outcome == 'failure' }}
60+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
61+
with:
62+
commit-message: "Document package (GHA)"
63+
branch: auto-document-code
64+
delete-branch: true
65+
title: "Document package (GHA)"
66+
labels: maintenance
67+
base: ${{ github.event.pull_request.base.ref }}
68+
body: |
69+
This Pull Request was automatically created to apply documentation changes to your code.
70+
Please review and merge this PR.
71+
assignees: ${{ github.actor }}
72+
reviewers: ${{ github.actor }}

.github/workflows/phs_package_checks.yaml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ permissions:
1515
contents: read
1616
pull-requests: read
1717
statuses: read
18-
18+
1919
jobs:
2020
# Initial job to post status
2121
init:
@@ -35,8 +35,18 @@ jobs:
3535
description: 'Package checks in progress',
3636
context: 'PHS Package Checks'
3737
});
38-
Style_and_document:
39-
uses: ./.github/workflows/phs_style_and_document.yaml
38+
Style:
39+
uses: ./.github/workflows/phs_style.yaml
40+
permissions:
41+
contents: write
42+
pull-requests: write
43+
secrets: inherit
44+
concurrency:
45+
group: ${{ github.workflow }}-${{ github.ref }}
46+
cancel-in-progress: true
47+
Document:
48+
needs: [Style]
49+
uses: ./.github/workflows/phs_document.yaml
4050
permissions:
4151
contents: write
4252
pull-requests: write
@@ -45,7 +55,7 @@ jobs:
4555
group: ${{ github.workflow }}-${{ github.ref }}
4656
cancel-in-progress: true
4757
R-CMD-check-core:
48-
needs: [Style_and_document]
58+
needs: [Style, Document]
4959
uses: ./.github/workflows/phs_R-CMD-check-core.yaml
5060
permissions:
5161
contents: read
@@ -54,7 +64,7 @@ jobs:
5464
group: ${{ inputs.limit_parallel == false && format('r-cmd-check-{0}-{1}', github.workflow, github.run_id) || 'phs-core-check-queue' }}
5565
cancel-in-progress: false
5666
R-CMD-check-extended:
57-
needs: [Style_and_document]
67+
needs: [R-CMD-check-core]
5868
uses: ./.github/workflows/phs_R-CMD-check-extended.yaml
5969
permissions:
6070
contents: read
@@ -63,7 +73,7 @@ jobs:
6373
group: ${{ inputs.limit_parallel == false && format('r-cmd-check-{0}-{1}', github.workflow, github.run_id) || 'package-checks-queue' }}
6474
cancel-in-progress: false
6575
R-CMD-check-no-suggests:
66-
needs: [R-CMD-check-core]
76+
needs: [R-CMD-check-extended]
6777
uses: ./.github/workflows/phs_R-CMD-check-no-suggests.yaml
6878
permissions:
6979
contents: read
@@ -81,14 +91,15 @@ jobs:
8191
group: ${{ inputs.limit_parallel == false && format('test-coverage-{0}-{1}', github.workflow, github.run_id) || 'package-checks-queue' }}
8292
cancel-in-progress: false
8393
pkgdown:
84-
needs: [Style_and_document]
94+
needs: [Document]
8595
uses: ./.github/workflows/phs_pkgdown.yaml
8696
permissions:
8797
contents: write
8898
secrets: inherit
99+
89100
# Final job to update status
90101
finalize:
91-
needs: [Style_and_document, R-CMD-check-core, test-coverage, pkgdown]
102+
needs: [Style, Document, R-CMD-check-core, test-coverage, pkgdown]
92103
runs-on: ubuntu-latest
93104
if: always()
94105
permissions:
@@ -98,11 +109,10 @@ jobs:
98109
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
99110
with:
100111
script: |
101-
const allSuccess = ${{ needs.Style_and_document.result == 'success' &&
102-
needs.R-CMD-check-core.result == 'success' &&
103-
needs.test-coverage.result == 'success' &&
104-
needs.pkgdown.result == 'success' }};
105-
112+
const allSuccess = ${{ needs.Style.result == 'success' &&
113+
needs.Document.result == 'success' &&
114+
needs.R-CMD-check-core.result == 'success' &&
115+
needs.test-coverage.result == 'success'}};
106116
await github.rest.repos.createCommitStatus({
107117
owner: context.repo.owner,
108118
repo: context.repo.repo,

.github/workflows/phs_style.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
workflow_call:
5+
6+
name: phs_style.yaml
7+
8+
permissions:
9+
contents: read
10+
pull-requests: read
11+
12+
jobs:
13+
phs_style:
14+
name: "Automatically style the code using air"
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
env:
20+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
21+
steps:
22+
- name: Checkout repo
23+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
with:
25+
fetch-depth: 0
26+
ref: ${{ github.event.pull_request.head.sha }}
27+
28+
- name: Install posit-dev/air
29+
uses: posit-dev/setup-air@63e80dedb6d275c94a3841e15e5ff8691e1ab237 # v1.0.0
30+
31+
- name: Include standard air.toml (overwrite existing)
32+
run: |
33+
echo '[format]' > air.toml
34+
echo 'line-ending = "lf"' >> air.toml
35+
36+
- name: Add air.toml to .Rbuildignore if it exists
37+
run: |
38+
if [ -f .Rbuildignore ]; then
39+
grep -qxF 'air.toml' .Rbuildignore || echo 'air.toml' >> .Rbuildignore
40+
fi
41+
42+
- name: Format using air
43+
run: air format .
44+
45+
- name: Commit and push changes
46+
id: commit_step_style
47+
uses: stefanzweifel/git-auto-commit-action@b863ae1933cb653a53c021fe36dbb774e1fb9403 # v5.2.0
48+
with:
49+
commit_message: "Style code (GHA)"
50+
continue-on-error: true
51+
52+
- name: Create Pull Request
53+
if: ${{ steps.commit_step_style.outputs.changes_detected == 'true' && steps.commit_step_style.outcome == 'failure' }}
54+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
55+
with:
56+
commit-message: "Style code (GHA)"
57+
branch: auto-style-code
58+
delete-branch: true
59+
title: "Style code (GHA)"
60+
labels: maintenance
61+
base: ${{ github.event.pull_request.base.ref }}
62+
body: |
63+
This Pull Request was automatically created to apply styling changes to your code.
64+
Please review and merge this PR.
65+
assignees: ${{ github.actor }}
66+
reviewers: ${{ github.actor }}
67+

.github/workflows/phs_style_and_document.yaml

Lines changed: 0 additions & 127 deletions
This file was deleted.

0 commit comments

Comments
 (0)