-
Notifications
You must be signed in to change notification settings - Fork 3
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
Merged
dfsnow
merged 12 commits into
master
from
15-refactor-gha-composable-workflow-to-use-action-instead
Aug 8, 2023
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fbed80f
Refactor GHA to use composite action instead of workflow
dfsnow 33dfdca
Checkout before running local action
dfsnow 8f5f901
Fix for secret inheritance for composite action
dfsnow fbe1a0a
Add missing shell config
dfsnow 84261d4
Keep database file when decompressed and quiet s3 cp
dfsnow fb8936a
Add missing shell config
dfsnow 9f94f34
Replace grep -P with sed for OS compatibility
dfsnow c799892
Fix path to DESCRIPTION on Windows
dfsnow 16fa614
Prevent DB files from being copied for pkg build
dfsnow c60142d
Move PTAXSIM prep stage after R setup
dfsnow 938f629
Remove split restore/save cache steps
dfsnow 36b1ab6
Set explicit workspace path to fix Windows path not found
dfsnow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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$ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
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: Cache database | ||
uses: actions/[email protected] | ||
id: cache_db | ||
with: | ||
path: ptaxsim.db.bz2 | ||
key: ${{ format('{0}-{1}', env.PTAXSIM_VERSION, hashFiles('DESCRIPTION')) }} | ||
enableCrossOsArchive: true | ||
|
||
- name: Configure AWS credentials | ||
if: steps.cache_db.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.cache_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 --quiet | ||
shell: bash | ||
|
||
- name: Unpack database (Linux) | ||
if: runner.os == 'Linux' | ||
run: | | ||
sudo apt-get install -y pbzip2 | ||
pbzip2 -dk ${{ github.workspace }}/ptaxsim.db.bz2 | ||
shell: bash | ||
|
||
- name: Unpack database (macOS) | ||
if: runner.os == 'macOS' | ||
run: | | ||
brew install pbzip2 | ||
pbzip2 -dk ${{ github.workspace }}/ptaxsim.db.bz2 | ||
shell: bash | ||
|
||
- name: Unpack database (Windows) | ||
if: runner.os == 'Windows' | ||
run: | | ||
7z x ${{ github.workspace }}/ptaxsim.db.bz2 | ||
shell: cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.