Skip to content

Commit

Permalink
Cleanup GitHub Actions workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
dfsnow committed Jul 14, 2023
1 parent 0299012 commit 67532ce
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 63 deletions.
23 changes: 10 additions & 13 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
workflow_dispatch:
pull_request:
push:
branches: [main, master]
Expand All @@ -16,9 +13,7 @@ jobs:
R-CMD-check:
needs: prepare-ptaxsim
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
Expand All @@ -28,24 +23,25 @@ jobs:
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
PTAXSIM_DB_PATH: ${{ github.workspace }}/ptaxsim.db
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2
- name: Setup pandoc
uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
- name: Setup R
uses: r-lib/actions/setup-r@v2
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
- name: Setup R dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check
Expand Down Expand Up @@ -77,6 +73,7 @@ jobs:
run: 7z x ptaxsim.db.bz2
shell: cmd

- uses: r-lib/actions/check-r-package@v2
- name: Check R package
uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
13 changes: 6 additions & 7 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
pull_request:
push:
Expand All @@ -10,16 +8,17 @@ name: lint
jobs:
lint:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
- name: Setup R dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::lintr, local::.
needs: lint
Expand Down
40 changes: 21 additions & 19 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
workflow_dispatch:
pull_request:
Expand All @@ -14,32 +12,25 @@ jobs:
uses: ./.github/workflows/prepare-ptaxsim.yaml
secrets: inherit

pkgdown:
build-pkgdown-site:
needs: prepare-ptaxsim
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
PTAXSIM_DB_PATH: ${{ github.workspace }}/ptaxsim.db
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
cancel-in-progress: false
permissions:
contents: read
pages: write
id-token: write
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2
- name: Setup pandoc
uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
- name: Setup R dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website
Expand All @@ -57,7 +48,7 @@ jobs:
pbzip2 -d ptaxsim.db.bz2
shell: bash

- name: Build site
- name: Build pkgdown site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

Expand All @@ -69,6 +60,17 @@ jobs:
with:
path: 'docs'

deploy:
if: contains(fromJSON('["main", "master"]'), github.ref_name) && github.event_name != 'pull_request'
needs: build-pkgdown-site
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write
id-token: write
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
23 changes: 16 additions & 7 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,28 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3

# Replacement for pre-commit/action
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.x

- run: python -m pip install pre-commit
- name: Install pre-commit
run: python -m pip install pre-commit
shell: bash

- run: python -m pip freeze --local
- name: Freeze dependencies
run: python -m pip freeze --local
shell: bash

- run: pre-commit run --show-diff-on-failure --color=always --all-files
- name: Cache pre-commit environment
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit-3-${{ env.pythonLocation }}-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Run pre-commit
run: pre-commit run --show-diff-on-failure --color=always --all-files
shell: bash
19 changes: 10 additions & 9 deletions .github/workflows/prepare-ptaxsim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,33 @@ jobs:
output1: ${{ steps.version_db.outputs.PTAXSIM_VERSION }}

steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3

- id: version_db
name: Get database version
- name: Get database version
id: version_db
run: |
echo "PTAXSIM_VERSION=$(grep -Po "(?<=Wants_DB_Version: )[0-9]*\.[0-9]*\.[0-9]*" ${{ github.workspace }}/DESCRIPTION)" >> $GITHUB_ENV
echo "PTAXSIM_VERSION=$(grep -Po "(?<=Wants_DB_Version: )[0-9]*\.[0-9]*\.[0-9]*" ${{ github.workspace }}/DESCRIPTION)" >> $GITHUB_OUTPUT
- id: check_db
name: Check database cache
- name: Check database cache
uses: actions/cache/restore@v3
id: check_db
with:
path: ptaxsim.db.bz2
key: ${{ format('{0}-{1}', env.PTAXSIM_VERSION, hashFiles('DESCRIPTION')) }}
lookup-only: true

- id: fetch_db
name: Fetch database file
- name: Fetch database file
id: fetch_db
if: steps.check_db.outputs.cache-hit != 'true'
run: |
aws s3 cp ${{ inputs.PTAXSIM_DB_BASE_URL }}/ptaxsim-${{ env.PTAXSIM_VERSION }}.db.bz2 ${{ github.workspace }}/ptaxsim.db.bz2
shell: bash

- id: save_db
name: Save database cache
- name: Save database cache
uses: actions/cache/save@v3
id: save_db
if: steps.check_db.outputs.cache-hit != 'true'
with:
path: ptaxsim.db.bz2
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
workflow_dispatch:
pull_request:
push:
branches: [main, master]
Expand All @@ -17,17 +14,18 @@ jobs:
needs: prepare-ptaxsim
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
PTAXSIM_DB_PATH: ${{ github.workspace }}/ptaxsim.db

steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
- name: Setup R dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
needs: coverage
Expand Down

0 comments on commit 67532ce

Please sign in to comment.