Skip to content

Commit

Permalink
Improve GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Felixmil committed Dec 16, 2024
1 parent d386be6 commit 2a08ef2
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 57 deletions.
22 changes: 9 additions & 13 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,32 @@ jobs:
fail-fast: false
matrix:
config:
# - {os: macos-latest, r: 'release'}
- {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
with:
ref: ${{ github.ref }}

- uses: r-lib/actions/setup-pandoc@v2

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x

- 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

- name: install ubuntu dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install dotnet-runtime-8.0 libcurl4-openssl-dev libssl-dev libxml2-dev
sudo apt-get install libfontconfig1-dev libharfbuzz-dev libfribidi-dev
sudo apt-get install libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libdl.so.2 /usr/lib/x86_64-linux-gnu/libdl.so
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
Expand All @@ -67,7 +63,7 @@ jobs:

- name: Get package version from DESCRIPTION file and set as environment variable
run: |
echo "PKG_VERSION=$(grep -oP '(?<=Version: )\d+\.\d+\.\d+\.*\d*' DESCRIPTION)" >> $GITHUB_ENV
echo "PKG_VERSION=$(grep '^Version: ' DESCRIPTION | sed -E 's/^Version: ([0-9]+\.[0-9]+\.[0-9]+\.?[0-9]*)/\1/')" >> $GITHUB_ENV
echo "$PKG_VERSION"
shell: bash

Expand Down
27 changes: 7 additions & 20 deletions .github/workflows/build-c#.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,17 @@ on:

jobs:
Linux-Build:

runs-on: ubuntu-22.04
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request' }}
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- uses: actions/checkout@v4
if: ${{ github.event_name != 'pull_request' }}

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
Expand All @@ -46,27 +41,24 @@ jobs:
- uses: EndBug/add-and-commit@v9
if: ${{ success() }}
with:
pull: '--verbose'
message: 'Update Linux C# binaries (Commit from Github Actions).'
default_author: github_actions
add: '*.so'
add: '*linux.so'


macOS-Build:
needs: Linux-Build
runs-on: macos-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request' }}
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- uses: actions/checkout@v4
if: ${{ github.event_name != 'pull_request' }}

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
Expand All @@ -81,7 +73,6 @@ jobs:
working-directory: ./shared
run: make


- name: Test C# binaries
run: |
export R_HOME=/Library/Frameworks/R.framework/Resources
Expand All @@ -92,27 +83,24 @@ jobs:
- uses: EndBug/add-and-commit@v9
if: ${{ success() }}
with:
pull: '--verbose'
message: 'Update macOS C# binaries (Commit from Github Actions).'
default_author: github_actions
add: '*.so'
add: '*mac.so'


Windows-Build:
needs: macOS-Build
runs-on: windows-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request' }}
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- uses: actions/checkout@v4
if: ${{ github.event_name != 'pull_request' }}

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
Expand All @@ -123,7 +111,6 @@ jobs:
with:
use-public-rspm: true


- name: Install dependencies
run: |
nuget restore ./shared/packages.config -PackagesDirectory ./shared/packages
Expand All @@ -143,10 +130,10 @@ jobs:
dotnet test .\shared\rSharpTests\ -c Release -d log.txt --no-build
dotnet test .\shared\DynamicInterop.Tests\ -c Release -d log.txt --no-build
- uses: EndBug/add-and-commit@v9
if: ${{ success() }}
with:
pull: '--verbose'
message: 'Update Windows C# binaries (Commit from Github Actions).'
default_author: github_actions
add: '*.dll'
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
name: PR-Workflow

on:
push:
branches: [main]
pull_request:
workflow_dispatch:


jobs:


# Detect changes done in C# code base. If no change were done, skim "build-Csharp-binaries" workflow.
changes:
detect-changes:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
pull-requests: read
Expand All @@ -17,22 +21,36 @@ jobs:
- uses: dorny/paths-filter@v3
id: filter
with:
base: ${{ github.ref }}
filters: |
Csharp:
- 'shared/**'
build-Csharp-binaries:
needs: changes
if: ${{ needs.changes.outputs.Csharp == 'true' }}
needs: detect-changes
if: ${{ needs.detect-changes.outputs.Csharp == 'true' && github.event_name == 'pull_request'}}
uses: ./.github/workflows/build-c#.yaml

# Automatically bump dev version when a it is a push to main branch
bump-dev-version:
needs: build-Csharp-binaries
if: github.event_name != 'pull_request' # only when merging in main/develop branch
uses: Open-Systems-Pharmacology/Workflows/.github/workflows/bump_dev_version_tag_branch.yaml@main
with:
app-id: ${{ vars.VERSION_BUMPER_APPID }}
secrets:
private-key: ${{ secrets.VERSION_BUMPER_SECRET }}

R-CMD-Check:
if: ${{ !cancelled() }}
needs: build-Csharp-binaries
needs: bump-dev-version
uses: ./.github/workflows/R-CMD-check.yaml

test-coverage:
if: ${{ !cancelled() }}
needs: [R-CMD-Check]
uses: ./.github/workflows/test-coverage.yaml

pkgdown:
if: ${{ !cancelled() }}
needs: [R-CMD-Check]
Expand Down
18 changes: 0 additions & 18 deletions .github/workflows/merge-workflow.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion tests/testthat/test-basic.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test_that("Methods with variable number of parameters with c# 'params' keyword",

test_that("Vignette examples work", {
assemblyPath <- system.file("extdata", "rSharp.Examples.dll", package = "rSharp")
# expect_true(loadAssembly(assemblyPath))
# expect_true(loadAssembly(assemblyPath)) # Returns FALSE on macos but TRUE on other platforms
expect_no_error(loadAssembly(assemblyPath))
expect_true(isAssemblyLoaded("rSharp.Examples"))
testObj <- newObjectFromName("rSharp.Examples.SampleInstanceClass")
Expand Down

0 comments on commit 2a08ef2

Please sign in to comment.