trying to implement a workflow on Github actions that will run a test script with the functions of my package and ideally print/export out the results. I am new to the YAML syntax and would appreciate any help.
This is the workflow I currently have:
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
name: Test-Script
jobs:
build:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
steps:
- uses: actions/checkout#v2
- uses: r-lib/actions/setup-r#v1
with:
r-version: ${{ matrix.config.r }}
- uses: r-lib/actions/setup-pandoc#v1
- name: Test against test script
run: |
/R/test_script.R #file path in repo
shell: Rscript {0}
I get the erorr: Error: Error: unexpected '/' in "/". I have tried multiple adjustments but always get that error or another saying that the file cannot be found. I would also like to print out/export out the results but I do not know how to do so.
Would appreciate any help please. Thank you.
Related
I'm tasked to automate a dotnet build and deployment process on GitHub. Earlier the engineers were manually building the solution on VScode and didn't face this issue.
Here's the Error screenshot: Build Error Screenshot
Here's my workflow file:
name: Build_Artifacts_Pipeline
on:
push:
branches:
- 'cs1_pipeline_test'
jobs:
build_artifacts:
runs-on: [windows-2019]
steps:
- name: pre-checkout
run:
git config --system core.longpaths true
- name: checkout repo
uses: actions/checkout#v3
- name: Setup MSBuild
uses: microsoft/setup-msbuild#v1.1
with:
vs-version: '15.0'
- name: Create a deploy folder
run: |
cd
mkdir D:\a\CS\Deploy_Reports
- name: Setup dotnet
uses: actions/setup-dotnet#v2
with:
dotnet-version: '5.0'
DOTNET_NOLOGO: 'true'
DOTNET_CLI_TELEMETRY_OPTOUT: 'true'
- name: Setup NuGet
uses: Nuget/setup-nuget#v1
with:
nuget-version: '6.0.2'
- name: Cache NuGet Packages
uses: actions/cache#v1
id: cache
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
# - name: NuGet Restore
# if: steps.cache.outputs.cache-hit != 'true'
# run: nuget restore ./WBC.sln
- name: Build Dotnet Framework Project
run: |
nuget install ./WBC.UI.Reporting.Web/packages.config -Source http://nuget.org/api/v2
msbuild ./WBC.UI.Reporting.Web/WBC.UI.Reporting.Web.csproj /p:GenerateSerializationAssemblies=Off /t:Build /p:DeployOnBuild=true /p:Configuration=Release /p:PublishProfile=NewProfile.pubxml /p:OutDir=D:\a\CS\Deploy_Reports\
Here's my csproj: .csproj
This is cross posted on the RStudio Community site. I am using r-lib/setup-r-dependencies#v2 for a bookdown project on GitHub action. However, the job is stalling when pak tries to create a lock file. Here is an example run , and here is the workflow.
As you can see, eventually the job just times out.
The issue seems similar to this post. The solution there was to use the most current RSPM, but I believe that is already what I am using (I don't specify anything different in the workflow).
Any ideas on what might be causing this?
Edit: Here is the full yaml code for the workflow (linked above)
on:
push:
branches: [main, master]
workflow_dispatch:
name: bookdown
jobs:
bookdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout#v2
- uses: r-lib/actions/setup-pandoc#v2
- uses: r-lib/actions/setup-r#v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies#v2
with:
cache-version: 1
- name: Cache bookdown results
uses: actions/cache#v2
with:
path: _bookdown_files
key: bookdown-${{ hashFiles('**/*Rmd') }}
restore-keys: bookdown-
- name: Build site
run: bookdown::render_book("index.Rmd", quiet = TRUE)
shell: Rscript {0}
- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action#4.1.4
with:
branch: gh-pages
folder: _book
I am struggling to replace values in my appsettings.json file and was wondering where I'm going wrong?
I have created two secrets in GitHub entitled COSMOSDBSETTINGS_SERVICEENDPOINT and COSMOSDBSETTINGS_AUTHKEY.
- name: Publish
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
- name: App Settings Variable Substitution
uses: microsoft/variable-substitution#v1
with:
files: '${{env.DOTNET_ROOT}}\myapp\appsettings.json'
env:
CosmosDbSettings:ServiceEndpoint: ${{ secrets.COSMOSDBSETTINGS_SERVICEENDPOINT }}
CosmosDbSettings:AuthKey: ${{ secrets.COSMOSDBSETTINGS_AUTHKEY }}
I get the error stating
Run microsoft/variable-substitution#v1
Applying variable substitution on JSON file: C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\myapp\appsettings.json
Skipped updating file: C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\myapp\appsettings.json
Error: Error: Failed to apply variable substitution
This is the appsettings locally:
"CosmosDbSettings": {
"ServiceEndpoint": "https://localhost:8081/",
"AuthKey": "KEY"
},
Use a dot instead of a colon:
env:
CosmosDbSettings.ServiceEndpoint: ${{ secrets.COSMOSDBSETTINGS_SERVICEENDPOINT }}
CosmosDbSettings.AuthKey: ${{ secrets.COSMOSDBSETTINGS_AUTHKEY }}
(GH newb attempting to cargo cult my way through some configuration ...)
I am using the GitHub actions YAML file here to test an R package. By default this workflow tests on four separate platforms, but this is overkill for my day-to-day needs. (This action does more limited testing, but I think? it also misses some stuff I wanted from the fuller workflow ...)
I would like to have the tests done on all four platforms only if the commit message includes the string "full check", otherwise testing just one platform. I know I can in principle achieve something like this if I include a conditional:
if: "contains(github.event.head_commit.message, '[full ci]')"
but I'm not sure of the precise syntax for including it in the workflow (and I'm afraid of spending many hours on trial-and-error attempts)
The chunk of the workflow that defines the set of platforms current looks like this, with three of the platforms commented out:
strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
## - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
## - {os: windows-latest, r: 'release'}
## - {os: macOS-latest, r: 'release'}
I'm assuming that just sticking the if: clause below the first row won't work (because it would break up the list). I suppose something like this might work?
matrix:
config:
if: "! contains(github.event.head_commit.message, '[full ci]')"]
config:
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
if: "contains(...)"
config:
[list with all four configs]
(Does this syntax have an if/else construct?)
I'm looking for answers that help me achieve the narrow goal, and hopefully understand the YAML syntax a little better (I have tried to read the FM ...)
I believe it is not possible to add conditions to the matrix construct itself. You could generate the matrix data beforehand in another job and then use it in your job.
There is a simpler solution: Use two jobs, because if can be used at the job level. Copy the current job that you have and then add if-conditions to each job. Keep one job as it is for the full CI and in the other job hardcode your environment for the ordinary commits.
Something like this:
jobs:
R-CMD-check-ordinary:
if: ${{ ! contains(github.event.head_commit.message, '[full ci]') }}
# Hardcode os
runs-on: ubuntu-20.04
# Hardcode name
name: Test only on Ubuntu
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
# replace any occurences of matrix.config. with hardcoded values
...
# And the original job
R-CMD-check-full:
if: ${{ contains(github.event.head_commit.message, '[full ci]') }}
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
...
Regarding YAML syntax:
YAML is a data format. Don't think of YAML as a script or program. A YAML file is similar to a list of command line arguments for a program. It only defines input data for another program.
So there is no if in YAML. For YAML if: condition is like as any other key: value pair, there is no logic attached.
I've been unsucessfully trying to setup lintr package with GitHub actions (circleCi would be good too, since it's a private repo) to check PR and pushes.
My project is a book so i don't need package build checks, but only enforcing style since there are serveral authors.
I've read this readme and this article but i couldn't figure out what should a .yml file look like is this case.
Figured that out. Still need to cache lintr but at least it is working:
on:
push:
branches:
- master
pull_request:
branches:
- master
name: lint
jobs:
lint:
runs-on: macOS-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout#v2
- uses: r-lib/actions/setup-r#master
- name: Install lintr
run: install.packages("lintr")
shell: Rscript {0}
- name: Lint
run: lintr::lint_dir(linters = lintr::with_defaults(assignment_linter = NULL, line_length_linter = NULL, spaces_left_parentheses_linter = NULL), pattern = '[.]R$|[.]Rmd')
shell: Rscript {0}