Skip to content

Commit

Permalink
Update test-coverage.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
jharcum07 authored Oct 28, 2024
1 parent 884b96c commit 50e7245
Showing 1 changed file with 53 additions and 36 deletions.
89 changes: 53 additions & 36 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,50 +1,67 @@
# 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
name: R package binary build

on:
push:
branches: [main, master]
branches:
- main
pull_request:
branches: [main, master]

name: test-coverage
branches:
- main

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
# Step 2: Set up R on the runner
- name: Set up R
uses: r-lib/actions/setup-r@v2

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
needs: coverage
# Step 3: Install Pandoc (if you're building vignettes)
- name: Install Pandoc
run: |
choco install pandoc
pandoc --version
- name: Test coverage
# Step 4: Install R dependencies
- name: Install dependencies
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()
Rscript -e 'install.packages("remotes")'
Rscript -e 'remotes::install_deps(dependencies = TRUE)'
# Step 5: Build the package and binary
- name: Build package and binary
run: |
Rscript -e 'devtools::build(binary = TRUE)' # Build the binary package
# Step 6: Get the Version from DESCRIPTION
- name: Get Version from DESCRIPTION
id: get_version # An ID to reference this step's output later
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
VERSION=$(grep -E '^Version:' DESCRIPTION | awk '{print $2}')
echo "::set-output name=version::$VERSION"
# Step 7: Create a Release and upload the binary to GitHub Releases using the version
- name: Create GitHub Release
uses: actions/create-release@v1
with:
tag_name: "v${{ steps.get_version.outputs.version }}" # Dynamically use the version
release_name: "v${{ steps.get_version.outputs.version }} Release"
body: "Release notes for version ${{ steps.get_version.outputs.version }}."
draft: false # Set to true if you want to manually review before publishing
prerelease: false # Set to true if this is a pre-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Automatically provided by GitHub

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
# Step 8: Upload the binary as a release asset
- name: Upload Binary to Release
uses: actions/upload-release-asset@v1
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: "D:/a/tidBIT/tidBIT_*.zip" # Adjust the path to match your binary file
asset_name: "tidBIT-windows-binary.zip"
asset_content_type: application/zip

0 comments on commit 50e7245

Please sign in to comment.