diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index eb0b3103..0bda0444 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -14,11 +14,9 @@ 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 }} @@ -26,24 +24,22 @@ jobs: 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 @@ -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 diff --git a/.github/workflows/build-c#.yaml b/.github/workflows/build-c#.yaml index ad44c16f..40bc5eaa 100644 --- a/.github/workflows/build-c#.yaml +++ b/.github/workflows/build-c#.yaml @@ -6,7 +6,6 @@ on: jobs: Linux-Build: - runs-on: ubuntu-22.04 env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} @@ -14,14 +13,10 @@ jobs: 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: @@ -46,12 +41,13 @@ 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 }} @@ -59,14 +55,10 @@ jobs: 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: @@ -81,7 +73,6 @@ jobs: working-directory: ./shared run: make - - name: Test C# binaries run: | export R_HOME=/Library/Frameworks/R.framework/Resources @@ -92,12 +83,13 @@ 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 }} @@ -105,14 +97,10 @@ jobs: 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: @@ -123,7 +111,6 @@ jobs: with: use-public-rspm: true - - name: Install dependencies run: | nuget restore ./shared/packages.config -PackagesDirectory ./shared/packages @@ -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' diff --git a/.github/workflows/pr-workflow.yaml b/.github/workflows/main-workflow.yaml similarity index 55% rename from .github/workflows/pr-workflow.yaml rename to .github/workflows/main-workflow.yaml index a3ff8101..c5ff2345 100644 --- a/.github/workflows/pr-workflow.yaml +++ b/.github/workflows/main-workflow.yaml @@ -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 @@ -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] diff --git a/.github/workflows/merge-workflow.yaml b/.github/workflows/merge-workflow.yaml deleted file mode 100644 index da2e0279..00000000 --- a/.github/workflows/merge-workflow.yaml +++ /dev/null @@ -1,18 +0,0 @@ -name: Merge Workflow - -on: - push: - branches: - - main - workflow_dispatch: - - -jobs: - R-CMD-Check: - uses: ./.github/workflows/R-CMD-check.yaml - test-coverage: - needs: [R-CMD-Check] - uses: ./.github/workflows/test-coverage.yaml - pkgdown: - needs: [R-CMD-Check] - uses: ./.github/workflows/pkgdown.yaml diff --git a/tests/testthat/test-basic.R b/tests/testthat/test-basic.R index b2b65ff8..6186711c 100644 --- a/tests/testthat/test-basic.R +++ b/tests/testthat/test-basic.R @@ -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")