-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor GHA to use composite action instead of workflow #17
Changes from 10 commits
fbed80f
33dfdca
8f5f901
fbe1a0a
84261d4
fb8936a
9f94f34
c799892
16fa614
c60142d
938f629
36b1ab6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
\.lintr$ | ||
\.travis\.yml$ | ||
^.*\.Rproj$ | ||
^.*\.db$ | ||
^.*\.db.bz2$ | ||
^README\.Rmd$ | ||
^\.Rproj\.user$ | ||
^\.apt$ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Prepare PTAXSIM database | ||
description: Downloads and extracts the PTAXSIM database file from S3 | ||
inputs: | ||
PTAXSIM_DB_BASE_URL: | ||
required: false | ||
type: string | ||
default: "s3://ccao-data-public-us-east-1/ptaxsim" | ||
ASSUMED_ROLE: | ||
description: "AWS role used for S3" | ||
outputs: | ||
PTAXSIM_VERSION: | ||
description: "PTAXSIM database version" | ||
value: ${{ steps.version_db.outputs.PTAXSIM_VERSION }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get database version | ||
id: version_db | ||
run: | | ||
DESCRIPTION_PATH=$(echo "${{ github.workspace }}/DESCRIPTION" | sed 's/\\/\//g') | ||
echo "PTAXSIM_VERSION=$(sed -n 's/.*Wants_DB_Version: \([0-9]*\.[0-9]*\.[0-9]\).*/\1/p' $DESCRIPTION_PATH)" >> $GITHUB_ENV | ||
echo "PTAXSIM_VERSION=${{ env.PTAXSIM_VERSION }}" >> $GITHUB_OUTPUT | ||
shell: bash | ||
|
||
- name: Restore database cache | ||
uses: actions/cache/[email protected] | ||
id: restore_db_cache | ||
with: | ||
path: ptaxsim.db.bz2 | ||
key: ${{ format('{0}-{1}', env.PTAXSIM_VERSION, hashFiles('DESCRIPTION')) }} | ||
enableCrossOsArchive: true | ||
|
||
- name: Configure AWS credentials | ||
if: steps.restore_db_cache.outputs.cache-hit != 'true' | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
role-to-assume: ${{ inputs.ASSUMED_ROLE }} | ||
aws-region: us-east-1 | ||
|
||
- name: Fetch database file | ||
id: fetch_db | ||
if: steps.restore_db_cache.outputs.cache-hit != 'true' | ||
run: | | ||
aws s3 cp ${{ inputs.PTAXSIM_DB_BASE_URL }}/ptaxsim-${{ env.PTAXSIM_VERSION }}.db.bz2 ${{ github.workspace }}/ptaxsim.db.bz2 --quiet | ||
shell: bash | ||
|
||
- name: Unpack database (Linux) | ||
if: runner.os == 'Linux' | ||
run: | | ||
sudo apt-get install -y pbzip2 | ||
pbzip2 -dk ptaxsim.db.bz2 | ||
shell: bash | ||
|
||
- name: Unpack database (macOS) | ||
if: runner.os == 'macOS' | ||
run: | | ||
brew install pbzip2 | ||
pbzip2 -dk ptaxsim.db.bz2 | ||
shell: bash | ||
|
||
- name: Unpack database (Windows) | ||
if: runner.os == 'Windows' | ||
run: 7z x ptaxsim.db.bz2 | ||
shell: cmd | ||
|
||
- name: Save database cache | ||
uses: actions/cache/save@v3 | ||
id: save_db | ||
if: steps.restore_db_cache.outputs.cache-hit != 'true' | ||
with: | ||
path: ptaxsim.db.bz2 | ||
key: ${{ format('{0}-{1}', env.PTAXSIM_VERSION, hashFiles('DESCRIPTION')) }} | ||
enableCrossOsArchive: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Question, non-blocking] I'm not quite an expert on GA caching, what's the benefit for this action of splitting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No benefit at all, it's just an artifact of the complexity from pre-refactor. Fixed by 938f629! |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,9 @@ on: | |
name: R-CMD-check | ||
|
||
jobs: | ||
prepare-ptaxsim: | ||
uses: ./.github/workflows/prepare-ptaxsim.yaml | ||
secrets: inherit | ||
|
||
R-CMD-check: | ||
needs: prepare-ptaxsim | ||
runs-on: ${{ matrix.config.os }} | ||
name: ${{ matrix.config.os }} (${{ matrix.config.r }}) | ||
runs-on: ${{ matrix.config.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
|
@@ -26,6 +21,12 @@ jobs: | |
env: | ||
PTAXSIM_DB_PATH: ${{ github.workspace }}/ptaxsim.db | ||
R_KEEP_PKG_SOURCE: yes | ||
|
||
# Required for OIDC access to S3 | ||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
@@ -46,32 +47,10 @@ jobs: | |
extra-packages: any::rcmdcheck | ||
needs: check | ||
|
||
- name: Restore database cache | ||
uses: actions/cache/[email protected] | ||
- name: Prepare PTAXSIM database | ||
uses: ./.github/actions/prepare-ptaxsim | ||
with: | ||
path: ptaxsim.db.bz2 | ||
key: ${{ format('{0}-{1}', needs.prepare-ptaxsim.outputs.PTAXSIM_VERSION, hashFiles('DESCRIPTION')) }} | ||
fail-on-cache-miss: true | ||
enableCrossOsArchive: true | ||
|
||
- name: Unpack database (Linux) | ||
if: runner.os == 'Linux' | ||
run: | | ||
sudo apt-get install -y pbzip2 | ||
pbzip2 -d ptaxsim.db.bz2 | ||
shell: bash | ||
|
||
- name: Unpack database (macOS) | ||
if: runner.os == 'macOS' | ||
run: | | ||
brew install pbzip2 | ||
pbzip2 -d ptaxsim.db.bz2 | ||
shell: bash | ||
|
||
- name: Unpack database (Windows) | ||
if: runner.os == 'Windows' | ||
run: 7z x ptaxsim.db.bz2 | ||
shell: cmd | ||
ASSUMED_ROLE: ${{ secrets.AWS_IAM_ROLE_TO_ASSUME_ARN }} | ||
|
||
- name: Check R package | ||
uses: r-lib/actions/check-r-package@v2 | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to prevent the PTAXSIM database file from being copied into the build directory during install.