From fbed80f7ffc81808b845e2c8ac5bb778fe4f3fcf Mon Sep 17 00:00:00 2001 From: Dan Snow Date: Tue, 8 Aug 2023 15:07:08 +0000 Subject: [PATCH 01/12] Refactor GHA to use composite action instead of workflow --- .github/actions/prepare-ptaxsim/action.yaml | 73 +++++++++++++++++++++ .github/workflows/R-CMD-check.yaml | 43 +++--------- .github/workflows/pkgdown.yaml | 27 +++----- .github/workflows/prepare-ptaxsim.yaml | 57 ---------------- .github/workflows/test-coverage.yaml | 27 +++----- 5 files changed, 101 insertions(+), 126 deletions(-) create mode 100644 .github/actions/prepare-ptaxsim/action.yaml delete mode 100644 .github/workflows/prepare-ptaxsim.yaml diff --git a/.github/actions/prepare-ptaxsim/action.yaml b/.github/actions/prepare-ptaxsim/action.yaml new file mode 100644 index 0000000..ea096d9 --- /dev/null +++ b/.github/actions/prepare-ptaxsim/action.yaml @@ -0,0 +1,73 @@ +name: Prepare PTAXSIM DB +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" +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: | + echo "PTAXSIM_VERSION=$(grep -Po "(?<=Wants_DB_Version: )[0-9]*\.[0-9]*\.[0-9]*" ${{ github.workspace }}/DESCRIPTION)" >> $GITHUB_ENV + echo "PTAXSIM_VERSION=${{ env.PTAXSIM_VERSION }}" >> $GITHUB_OUTPUT + + - name: Restore database cache + uses: actions/cache/restore@v3.3.1 + 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: ${{ secrets.AWS_IAM_ROLE_TO_ASSUME_ARN }} + 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 + shell: bash + + - 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 + + - 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 diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index e0d023a..09c3e4c 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -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,7 +21,16 @@ 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: Prepare PTAXSIM DB + uses: ./.github/actions/prepare-ptaxsim + - name: Checkout uses: actions/checkout@v3 @@ -46,33 +50,6 @@ jobs: extra-packages: any::rcmdcheck needs: check - - name: Restore database cache - uses: actions/cache/restore@v3.3.1 - 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 - - name: Check R package uses: r-lib/actions/check-r-package@v2 with: diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 59ff4be..1f1c831 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -8,16 +8,20 @@ on: name: pkgdown jobs: - prepare-ptaxsim: - uses: ./.github/workflows/prepare-ptaxsim.yaml - secrets: inherit - build-pkgdown-site: - needs: prepare-ptaxsim runs-on: ubuntu-latest env: PTAXSIM_DB_PATH: ${{ github.workspace }}/ptaxsim.db + + # Required for OIDC access to S3 + permissions: + id-token: write + contents: read + steps: + - name: Prepare PTAXSIM DB + uses: ./.github/actions/prepare-ptaxsim + - name: Checkout uses: actions/checkout@v3 @@ -35,19 +39,6 @@ jobs: extra-packages: any::pkgdown, local::. needs: website - - name: Restore database cache - uses: actions/cache/restore@v3 - with: - path: ptaxsim.db.bz2 - key: ${{ format('{0}-{1}', needs.prepare-ptaxsim.outputs.PTAXSIM_VERSION, hashFiles('DESCRIPTION')) }} - fail-on-cache-miss: true - - - name: Unpack database - run: | - sudo apt-get install -y pbzip2 - pbzip2 -d ptaxsim.db.bz2 - shell: bash - - name: Build pkgdown site run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) shell: Rscript {0} diff --git a/.github/workflows/prepare-ptaxsim.yaml b/.github/workflows/prepare-ptaxsim.yaml deleted file mode 100644 index 527085b..0000000 --- a/.github/workflows/prepare-ptaxsim.yaml +++ /dev/null @@ -1,57 +0,0 @@ -on: - workflow_call: - inputs: - PTAXSIM_DB_BASE_URL: - required: false - type: string - default: "s3://ccao-data-public-us-east-1/ptaxsim" - outputs: - PTAXSIM_VERSION: - description: "PTAXSIM database version" - value: ${{ jobs.download-db.outputs.output1 }} - -name: prepare-ptaxsim - -jobs: - download-db: - runs-on: ubuntu-latest - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ secrets.AWS_REGION }} - outputs: - output1: ${{ steps.version_db.outputs.PTAXSIM_VERSION }} - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - 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 - - - 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 - - - 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 - - - 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 - key: ${{ format('{0}-{1}', env.PTAXSIM_VERSION, hashFiles('DESCRIPTION')) }} - enableCrossOsArchive: true diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index a240391..4d21397 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -6,16 +6,20 @@ on: name: test-coverage jobs: - prepare-ptaxsim: - uses: ./.github/workflows/prepare-ptaxsim.yaml - secrets: inherit - test-coverage: - needs: prepare-ptaxsim runs-on: ubuntu-latest env: PTAXSIM_DB_PATH: ${{ github.workspace }}/ptaxsim.db + + # Required for OIDC access to S3 + permissions: + id-token: write + contents: read + steps: + - name: Prepare PTAXSIM DB + uses: ./.github/actions/prepare-ptaxsim + - name: Checkout uses: actions/checkout@v3 @@ -30,19 +34,6 @@ jobs: extra-packages: any::covr needs: coverage - - name: Restore database cache - uses: actions/cache/restore@v3 - with: - path: ptaxsim.db.bz2 - key: ${{ format('{0}-{1}', needs.prepare-ptaxsim.outputs.PTAXSIM_VERSION, hashFiles('DESCRIPTION')) }} - fail-on-cache-miss: true - - - name: Unpack database - run: | - sudo apt-get install -y pbzip2 - pbzip2 -d ptaxsim.db.bz2 - shell: bash - - name: Test coverage run: | covr::codecov( From 33dfdca15b0a5e19723087f054fb01e0cada1714 Mon Sep 17 00:00:00 2001 From: Dan Snow Date: Tue, 8 Aug 2023 15:12:50 +0000 Subject: [PATCH 02/12] Checkout before running local action --- .github/workflows/R-CMD-check.yaml | 6 +++--- .github/workflows/pkgdown.yaml | 6 +++--- .github/workflows/test-coverage.yaml | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 09c3e4c..daa115c 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -28,12 +28,12 @@ jobs: contents: read steps: - - name: Prepare PTAXSIM DB - uses: ./.github/actions/prepare-ptaxsim - - name: Checkout uses: actions/checkout@v3 + - name: Prepare PTAXSIM DB + uses: ./.github/actions/prepare-ptaxsim + - name: Setup pandoc uses: r-lib/actions/setup-pandoc@v2 diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 1f1c831..c4444a9 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -19,12 +19,12 @@ jobs: contents: read steps: - - name: Prepare PTAXSIM DB - uses: ./.github/actions/prepare-ptaxsim - - name: Checkout uses: actions/checkout@v3 + - name: Prepare PTAXSIM DB + uses: ./.github/actions/prepare-ptaxsim + - name: Setup pandoc uses: r-lib/actions/setup-pandoc@v2 diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 4d21397..29e6088 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -17,12 +17,12 @@ jobs: contents: read steps: - - name: Prepare PTAXSIM DB - uses: ./.github/actions/prepare-ptaxsim - - name: Checkout uses: actions/checkout@v3 + - name: Prepare PTAXSIM DB + uses: ./.github/actions/prepare-ptaxsim + - name: Setup R uses: r-lib/actions/setup-r@v2 with: From 8f5f901dc4d4cdcc949e58fdb3efe51005e9ce16 Mon Sep 17 00:00:00 2001 From: Dan Snow Date: Tue, 8 Aug 2023 15:24:00 +0000 Subject: [PATCH 03/12] Fix for secret inheritance for composite action --- .github/actions/prepare-ptaxsim/action.yaml | 6 ++++-- .github/workflows/R-CMD-check.yaml | 4 +++- .github/workflows/pkgdown.yaml | 4 +++- .github/workflows/test-coverage.yaml | 4 +++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/actions/prepare-ptaxsim/action.yaml b/.github/actions/prepare-ptaxsim/action.yaml index ea096d9..2239c20 100644 --- a/.github/actions/prepare-ptaxsim/action.yaml +++ b/.github/actions/prepare-ptaxsim/action.yaml @@ -1,10 +1,12 @@ -name: Prepare PTAXSIM DB +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" @@ -34,7 +36,7 @@ runs: if: steps.restore_db_cache.outputs.cache-hit != 'true' uses: aws-actions/configure-aws-credentials@v2 with: - role-to-assume: ${{ secrets.AWS_IAM_ROLE_TO_ASSUME_ARN }} + role-to-assume: ${{ inputs.ASSUMED_ROLE }} aws-region: us-east-1 - name: Fetch database file diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index daa115c..4c6aa89 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -31,8 +31,10 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Prepare PTAXSIM DB + - name: Prepare PTAXSIM database uses: ./.github/actions/prepare-ptaxsim + with: + ASSUMED_ROLE: ${{ secrets.AWS_IAM_ROLE_TO_ASSUME_ARN }} - name: Setup pandoc uses: r-lib/actions/setup-pandoc@v2 diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index c4444a9..84f5964 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -22,8 +22,10 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Prepare PTAXSIM DB + - name: Prepare PTAXSIM database uses: ./.github/actions/prepare-ptaxsim + with: + ASSUMED_ROLE: ${{ secrets.AWS_IAM_ROLE_TO_ASSUME_ARN }} - name: Setup pandoc uses: r-lib/actions/setup-pandoc@v2 diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 29e6088..f3eff90 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -20,8 +20,10 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Prepare PTAXSIM DB + - name: Prepare PTAXSIM database uses: ./.github/actions/prepare-ptaxsim + with: + ASSUMED_ROLE: ${{ secrets.AWS_IAM_ROLE_TO_ASSUME_ARN }} - name: Setup R uses: r-lib/actions/setup-r@v2 From fbe1a0a8de8e32abf5ef79e20fd0fbb9d385b649 Mon Sep 17 00:00:00 2001 From: Dan Snow Date: Tue, 8 Aug 2023 15:26:11 +0000 Subject: [PATCH 04/12] Add missing shell config --- .github/actions/prepare-ptaxsim/action.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/prepare-ptaxsim/action.yaml b/.github/actions/prepare-ptaxsim/action.yaml index 2239c20..b7d2c46 100644 --- a/.github/actions/prepare-ptaxsim/action.yaml +++ b/.github/actions/prepare-ptaxsim/action.yaml @@ -23,6 +23,7 @@ runs: run: | echo "PTAXSIM_VERSION=$(grep -Po "(?<=Wants_DB_Version: )[0-9]*\.[0-9]*\.[0-9]*" ${{ github.workspace }}/DESCRIPTION)" >> $GITHUB_ENV echo "PTAXSIM_VERSION=${{ env.PTAXSIM_VERSION }}" >> $GITHUB_OUTPUT + shell: bash - name: Restore database cache uses: actions/cache/restore@v3.3.1 From 84261d48a5eb1738afcc4d2435b1006de819704a Mon Sep 17 00:00:00 2001 From: Dan Snow Date: Tue, 8 Aug 2023 15:41:25 +0000 Subject: [PATCH 05/12] Keep database file when decompressed and quiet s3 cp --- .github/actions/prepare-ptaxsim/action.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/actions/prepare-ptaxsim/action.yaml b/.github/actions/prepare-ptaxsim/action.yaml index b7d2c46..ce2e76b 100644 --- a/.github/actions/prepare-ptaxsim/action.yaml +++ b/.github/actions/prepare-ptaxsim/action.yaml @@ -23,7 +23,6 @@ runs: run: | echo "PTAXSIM_VERSION=$(grep -Po "(?<=Wants_DB_Version: )[0-9]*\.[0-9]*\.[0-9]*" ${{ github.workspace }}/DESCRIPTION)" >> $GITHUB_ENV echo "PTAXSIM_VERSION=${{ env.PTAXSIM_VERSION }}" >> $GITHUB_OUTPUT - shell: bash - name: Restore database cache uses: actions/cache/restore@v3.3.1 @@ -44,21 +43,21 @@ runs: 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 + 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 -d ptaxsim.db.bz2 + pbzip2 -dk ptaxsim.db.bz2 shell: bash - name: Unpack database (macOS) if: runner.os == 'macOS' run: | brew install pbzip2 - pbzip2 -d ptaxsim.db.bz2 + pbzip2 -dk ptaxsim.db.bz2 shell: bash - name: Unpack database (Windows) From fb8936aa90288ee3c183ceb6c9094bcb616ee523 Mon Sep 17 00:00:00 2001 From: Dan Snow Date: Tue, 8 Aug 2023 15:43:40 +0000 Subject: [PATCH 06/12] Add missing shell config --- .github/actions/prepare-ptaxsim/action.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/prepare-ptaxsim/action.yaml b/.github/actions/prepare-ptaxsim/action.yaml index ce2e76b..b15e662 100644 --- a/.github/actions/prepare-ptaxsim/action.yaml +++ b/.github/actions/prepare-ptaxsim/action.yaml @@ -23,6 +23,7 @@ runs: run: | echo "PTAXSIM_VERSION=$(grep -Po "(?<=Wants_DB_Version: )[0-9]*\.[0-9]*\.[0-9]*" ${{ github.workspace }}/DESCRIPTION)" >> $GITHUB_ENV echo "PTAXSIM_VERSION=${{ env.PTAXSIM_VERSION }}" >> $GITHUB_OUTPUT + shell: bash - name: Restore database cache uses: actions/cache/restore@v3.3.1 From 9f94f348556efc5ae902e30cac4ac5a04b46499f Mon Sep 17 00:00:00 2001 From: Dan Snow Date: Tue, 8 Aug 2023 16:05:06 +0000 Subject: [PATCH 07/12] Replace grep -P with sed for OS compatibility --- .github/actions/prepare-ptaxsim/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/prepare-ptaxsim/action.yaml b/.github/actions/prepare-ptaxsim/action.yaml index b15e662..1e940df 100644 --- a/.github/actions/prepare-ptaxsim/action.yaml +++ b/.github/actions/prepare-ptaxsim/action.yaml @@ -21,7 +21,7 @@ runs: - 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=$(sed -n 's/.*Wants_DB_Version: \([0-9]*\.[0-9]*\.[0-9]\).*/\1/p' ${{ github.workspace }}/DESCRIPTION)" >> $GITHUB_ENV echo "PTAXSIM_VERSION=${{ env.PTAXSIM_VERSION }}" >> $GITHUB_OUTPUT shell: bash From c799892bebf6d8c54bb46f94b3a91b980ad5dbbb Mon Sep 17 00:00:00 2001 From: Dan Snow Date: Tue, 8 Aug 2023 16:24:37 +0000 Subject: [PATCH 08/12] Fix path to DESCRIPTION on Windows --- .github/actions/prepare-ptaxsim/action.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/prepare-ptaxsim/action.yaml b/.github/actions/prepare-ptaxsim/action.yaml index 1e940df..e6ff4fa 100644 --- a/.github/actions/prepare-ptaxsim/action.yaml +++ b/.github/actions/prepare-ptaxsim/action.yaml @@ -21,7 +21,8 @@ runs: - name: Get database version id: version_db run: | - echo "PTAXSIM_VERSION=$(sed -n 's/.*Wants_DB_Version: \([0-9]*\.[0-9]*\.[0-9]\).*/\1/p' ${{ github.workspace }}/DESCRIPTION)" >> $GITHUB_ENV + 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 From 16fa614b258ea11aa6495aa1087f7d25d20f27e4 Mon Sep 17 00:00:00 2001 From: Dan Snow Date: Tue, 8 Aug 2023 16:41:20 +0000 Subject: [PATCH 09/12] Prevent DB files from being copied for pkg build --- .Rbuildignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.Rbuildignore b/.Rbuildignore index 2da9b6c..2ab4e99 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -15,6 +15,8 @@ \.lintr$ \.travis\.yml$ ^.*\.Rproj$ +^.*\.db$ +^.*\.db.bz2$ ^README\.Rmd$ ^\.Rproj\.user$ ^\.apt$ From c60142d14e52e6cffcdf747a85c7c49c908519cb Mon Sep 17 00:00:00 2001 From: Dan Snow Date: Tue, 8 Aug 2023 17:02:35 +0000 Subject: [PATCH 10/12] Move PTAXSIM prep stage after R setup --- .github/workflows/R-CMD-check.yaml | 10 +++++----- .github/workflows/pkgdown.yaml | 10 +++++----- .github/workflows/test-coverage.yaml | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 4c6aa89..e6e6f44 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -31,11 +31,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Prepare PTAXSIM database - uses: ./.github/actions/prepare-ptaxsim - with: - ASSUMED_ROLE: ${{ secrets.AWS_IAM_ROLE_TO_ASSUME_ARN }} - - name: Setup pandoc uses: r-lib/actions/setup-pandoc@v2 @@ -52,6 +47,11 @@ jobs: extra-packages: any::rcmdcheck needs: check + - name: Prepare PTAXSIM database + uses: ./.github/actions/prepare-ptaxsim + with: + ASSUMED_ROLE: ${{ secrets.AWS_IAM_ROLE_TO_ASSUME_ARN }} + - name: Check R package uses: r-lib/actions/check-r-package@v2 with: diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 84f5964..da46d29 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -22,11 +22,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Prepare PTAXSIM database - uses: ./.github/actions/prepare-ptaxsim - with: - ASSUMED_ROLE: ${{ secrets.AWS_IAM_ROLE_TO_ASSUME_ARN }} - - name: Setup pandoc uses: r-lib/actions/setup-pandoc@v2 @@ -41,6 +36,11 @@ jobs: extra-packages: any::pkgdown, local::. needs: website + - name: Prepare PTAXSIM database + uses: ./.github/actions/prepare-ptaxsim + with: + ASSUMED_ROLE: ${{ secrets.AWS_IAM_ROLE_TO_ASSUME_ARN }} + - name: Build pkgdown site run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) shell: Rscript {0} diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index f3eff90..c4d4298 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -20,11 +20,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Prepare PTAXSIM database - uses: ./.github/actions/prepare-ptaxsim - with: - ASSUMED_ROLE: ${{ secrets.AWS_IAM_ROLE_TO_ASSUME_ARN }} - - name: Setup R uses: r-lib/actions/setup-r@v2 with: @@ -36,6 +31,11 @@ jobs: extra-packages: any::covr needs: coverage + - name: Prepare PTAXSIM database + uses: ./.github/actions/prepare-ptaxsim + with: + ASSUMED_ROLE: ${{ secrets.AWS_IAM_ROLE_TO_ASSUME_ARN }} + - name: Test coverage run: | covr::codecov( From 938f629d91c108dd1f8c87ae14e4b503780f6c4d Mon Sep 17 00:00:00 2001 From: Dan Snow Date: Tue, 8 Aug 2023 18:21:34 +0000 Subject: [PATCH 11/12] Remove split restore/save cache steps --- .github/actions/prepare-ptaxsim/action.yaml | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/.github/actions/prepare-ptaxsim/action.yaml b/.github/actions/prepare-ptaxsim/action.yaml index e6ff4fa..6d09511 100644 --- a/.github/actions/prepare-ptaxsim/action.yaml +++ b/.github/actions/prepare-ptaxsim/action.yaml @@ -26,16 +26,16 @@ runs: echo "PTAXSIM_VERSION=${{ env.PTAXSIM_VERSION }}" >> $GITHUB_OUTPUT shell: bash - - name: Restore database cache - uses: actions/cache/restore@v3.3.1 - id: restore_db_cache + - name: Cache database + uses: actions/cache@v3.3.1 + 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.restore_db_cache.outputs.cache-hit != 'true' + if: steps.cache_db.outputs.cache-hit != 'true' uses: aws-actions/configure-aws-credentials@v2 with: role-to-assume: ${{ inputs.ASSUMED_ROLE }} @@ -43,7 +43,7 @@ runs: - name: Fetch database file id: fetch_db - if: steps.restore_db_cache.outputs.cache-hit != 'true' + 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 @@ -66,12 +66,3 @@ runs: 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 From 36b1ab6e58ace0c43b7587416d6080e9bd70ae2d Mon Sep 17 00:00:00 2001 From: Dan Snow Date: Tue, 8 Aug 2023 18:35:14 +0000 Subject: [PATCH 12/12] Set explicit workspace path to fix Windows path not found --- .github/actions/prepare-ptaxsim/action.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/actions/prepare-ptaxsim/action.yaml b/.github/actions/prepare-ptaxsim/action.yaml index 6d09511..e85024f 100644 --- a/.github/actions/prepare-ptaxsim/action.yaml +++ b/.github/actions/prepare-ptaxsim/action.yaml @@ -52,17 +52,18 @@ runs: if: runner.os == 'Linux' run: | sudo apt-get install -y pbzip2 - pbzip2 -dk ptaxsim.db.bz2 + pbzip2 -dk ${{ github.workspace }}/ptaxsim.db.bz2 shell: bash - name: Unpack database (macOS) if: runner.os == 'macOS' run: | brew install pbzip2 - pbzip2 -dk ptaxsim.db.bz2 + pbzip2 -dk ${{ github.workspace }}/ptaxsim.db.bz2 shell: bash - name: Unpack database (Windows) if: runner.os == 'Windows' - run: 7z x ptaxsim.db.bz2 + run: | + 7z x ${{ github.workspace }}/ptaxsim.db.bz2 shell: cmd