diff --git a/.github/workflow-resources/release-version-check.sh b/.github/workflow-resources/release-version-check.sh new file mode 100755 index 0000000..3463c99 --- /dev/null +++ b/.github/workflow-resources/release-version-check.sh @@ -0,0 +1,7 @@ +# assumes $INPUT_VERSION is set to the selected release version +CURRENT_VERSION=$(echo "$(cat DESCRIPTION)" | grep "Version:" | awk '{print $2}') + +if [ "$(printf '%s\n' "$INPUT_VERSION" "$CURRENT_VERSION" | sort -V | head -n1)" = "$INPUT_VERSION" ]; then + echo "::error title=Invalid version::Provided version number must be higher than the current version ($CURRENT_VERSION)." + exit 1 +fi diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 9bb6413..d43c7fd 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -1,4 +1,5 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples + +name: check on: push: @@ -6,45 +7,7 @@ on: pull_request: branches: master -name: check - jobs: check: - runs-on: ${{ matrix.config.os }} - - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - - strategy: - fail-fast: false - matrix: - config: - - {os: macos-latest, r: 'release'} - - {os: windows-latest, r: 'release'} - - {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 }} - R_KEEP_PKG_SOURCE: yes - - steps: - - uses: actions/checkout@v4 - - - uses: r-lib/actions/setup-pandoc@v2 - - - 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 - with: - extra-packages: any::rcmdcheck - needs: check - - - uses: r-lib/actions/check-r-package@v2 - with: - upload-snapshots: true - build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' + uses: pdil/usmapdata/.github/workflows/check.yaml@master + secrets: inherit diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..34c5868 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,16 @@ + +name: lint + +on: + push: + branches: master + pull_request: + branches: master + +jobs: + lint: + permissions: + # for github/codeql-action/upload-sarif to upload SARIF results + security-events: write + uses: pdil/usmapdata/.github/workflows/lint.yaml@master + secrets: inherit diff --git a/.github/workflows/lintr.yml b/.github/workflows/lintr.yml deleted file mode 100644 index b80661f..0000000 --- a/.github/workflows/lintr.yml +++ /dev/null @@ -1,47 +0,0 @@ -# lintr provides static code analysis for R. -# It checks for adherence to a given style, -# identifying syntax errors and possible semantic issues, -# then reports them to you so you can take action. -# More details at https://lintr.r-lib.org/ - -name: lintr - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -permissions: - contents: read - -jobs: - lintr: - name: Run lintr scanning - runs-on: ubuntu-latest - permissions: - contents: read # for checkout to fetch code - security-events: write # for github/codeql-action/upload-sarif to upload SARIF results - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup R - uses: r-lib/actions/setup-r@v2 - - - name: Setup lintr - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: lintr - - - name: Run lintr - run: lintr::sarif_output(lintr::lint_dir("."), "lintr-results.sarif") - shell: Rscript {0} - continue-on-error: true - - - name: Upload analysis results to GitHub - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: lintr-results.sarif - wait-for-processing: true diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 68e3ee5..3c0caa9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,5 +1,6 @@ name: release +run-name: Release ${{ github.event.repository.name }} ${{ inputs.version }} on: workflow_dispatch: @@ -11,73 +12,7 @@ on: jobs: release: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup R - uses: r-lib/actions/setup-r@v2 - - - name: Install R dependencies - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: | - any::devtools - any::rhub - github::r-lib/revdepcheck - - - name: Run release checks - env: - EMAIL: ${{ secrets.RHUB_EMAIL }} - TOKEN: ${{ secrets.RHUB_TOKEN }} - VERSION: ${{ inputs.version }} - run: | - source(".github/workflow-resources/release-checklist.R") - release_checklist( - Sys.getenv("EMAIL"), - Sys.getenv("TOKEN"), - Sys.getenv("VERSION") - ) - shell: Rscript {0} - - - name: Update NEWS.md version - uses: jacobtomlinson/gha-find-replace@v3 - with: - find: "[unreleased]" - replace: "usmap ${{ inputs.version }}" - include: "NEWS.md" - regex: false - - - name: Import GPG signing key - uses: crazy-max/ghaction-import-gpg@v6 - with: - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} - passphrase: ${{ secrets.GPG_PASSPHRASE }} - git_user_signingkey: true - git_commit_gpgsign: true - - - name: Render PR body - id: pr-body - uses: chuhlomin/render-template@v1 - with: - template: .github/workflow-resources/release-pr-body.md - vars: | - version: ${{ inputs.version }} - - - name: Open pull request - uses: peter-evans/create-pull-request@v6 - with: - token: ${{ secrets.BOT_PAT }} - author: ${{ secrets.BOT_USER }} - committer: ${{ secrets.BOT_USER }} - commit-message: "[automated] Prepare for ${{ inputs.version }} release" - branch: release/${{ inputs.version }} - title: Release version ${{ inputs.version }} - body: ${{ steps.pr-body.outputs.result }} - reviewers: pdil - assignees: pdil - labels: release - delete-branch: true - draft: true + uses: pdil/usmapdata/.github/workflows/release.yaml@master + secrets: inherit + with: + version: ${{ inputs.version }} diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 9b5dcb7..b3ed8fe 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -1,50 +1,13 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples + +name: test-coverage on: push: - branches: [main, master] + branches: master pull_request: - branches: [main, master] - -name: test-coverage + branches: master jobs: test-coverage: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v4 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::covr - needs: coverage - - - name: Test coverage - run: | - covr::codecov( - quiet = FALSE, - clean = FALSE, - install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") - ) - shell: Rscript {0} - - - name: Show testthat output - if: always() - run: | - ## -------------------------------------------------------------------- - find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash - - - name: Upload test results - if: failure() - uses: actions/upload-artifact@v4 - with: - name: coverage-test-failures - path: ${{ runner.temp }}/package + uses: pdil/usmapdata/.github/workflows/test-coverage.yaml@master + secrets: inherit