I am going through a course and I am getting a syntax error on the second last line below (shell: bash). Any ideas? If I remove that line I get the same error on the next line (run: npm ci).
name: Build, test, & deploy
on: [push]
jobs:
build:
name: Project build & package
if: "!contains(github.even.head_commit.message, '[skip-ci]'"
runs-on: ubuntu-latest
steps:
-name: checkout repo action
uses: actions/checkout#master
-name: Setup Node v10.x
uses: actions/setup-node#v1
with:
node-version:10.x
-name: Cache Node.js packages
uses: actions/cache#v1
env:
cache-name: cache-node-packages
with:
#use `~/npm` for macOS / Linux agents
# & '%AppData%/npm-cache' for Windows agents
path: ~./npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
-name: Resolve project dependencies with NPM
shell: bash
run: npm ci
The biggest problems were spacing and indentation. I also had a missing paren.
name: Build, test, & deploy
on: [push]
jobs:
build:
name: Project build & package
if: "!contains(github.even.head_commit.message, '[skip-ci]')"
runs-on: ubuntu-latest
steps:
- name: checkout repo action
uses: actions/checkout#master
- name: Setup Node v10.x
uses: actions/setup-node#v1
with:
node-version: 10.x
- name: Cache Node.js packages
uses: actions/cache#v1
env:
cache-name: cache-node-packages
with:
#use `~/npm` for macOS / Linux agents
# & '%AppData%/npm-cache' for Windows agents
path: ~./npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
- name: Resolve project dependencies with NPM
shell: bash
run: npm ci
Related
I have a non-gradle root project which should launch child gh action, but can’t figure out how to. File child.yml should generate apk artifact, since android/ dir is app directory.
Project structure:
root
|
--- .github/workflows/root.yml
--- android/
|
___ .github/actions/apk/child.yml
Closest I get was running a yaml on root level:
root.yml
name: use my action
on:
push:
branches:
- ci_test
jobs:
#Build job
test_build:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout#v2
- uses: ./android/.github/actions/apk
child.yml
name: Build of dev branch
on:
push:
branches:
- develop
jobs:
#Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout#v2
- uses: actions/cache#v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }}
- name: Set up JDK 11
uses: actions/setup-java#v1
with:
java-version: '11'
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Build the app
run: ./gradlew assembleDebug
- name: Upload apk
uses: actions/upload-artifact#v2
with:
name: debug apk
path: ./app/build/outputs/apk/debug/app-debug.apk
But I get an error with doubled "/my-root-dir/my-root-dir"
Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/my-root-dir/my-root-dir/android/.github/actions/child.yaml'. Did you forget to run actions/checkout before running your local action?
On every commit, I'm building my project on different Operating Systems. Therefore I'm using CMake as a build system for my C++ code.
In order to make the builds faster I tried to cache older builds, so not changed files don't have to be rebuilt.
I've written the following GH Action Script:
name: Build for MacOS, Ubuntu and Windows
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
BUILD_TYPE: Release
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, macos-11, windows-2022 ]
steps:
- uses: actions/checkout#v2
- name: Cache build
uses: actions/cache#v3
with:
path: ${{github.workspace}}/build
key: ${{ matrix.os }}-build
restore-keys: ${{ matrix.os }}-build
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DFORCE_COLORED_OUTPUT=1
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
Width ...
- name: Cache build
uses: actions/cache#v3
with:
path: ${{github.workspace}}/build
key: ${{ matrix.os }}-build
restore-keys: ${{ matrix.os }}-build
... I tried to cache the directory all the build files are written to, but it looks like the project is completely rebuilt every time.
Is there anything I'm doing wrong?
I uploaded all logs to https://pastebin.com/JLErAPyD
I would like to set up github action which
calls nuget and caches it
builds solution
runs unit tests
I managed to get the second and third step is working but it's now a problem to combine following first step.
- name: Cache Nuget
- uses: actions/cache#v1
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
I tried to put that after - uses: actions/checkout#v2 but It throws following error.
every step must define a `uses` or `run` key
...
steps:
- uses: actions/checkout#v2
- name: Cache Nuget
- uses: actions/cache#v1
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Setup .NET
uses: actions/setup-dotnet#v1
...
What am I doing wrong?
Thanks for help.
Here's the full config.
name: Build and Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Cache Nuget
- uses: actions/cache#v1
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Setup .NET
uses: actions/setup-dotnet#v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Run Tests
run: dotnet test --configuration Release --no-build --verbosity minimal /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov
- name: Publish coverage report to coveralls.io
uses: coverallsapp/github-action#master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: Tests/App.Tests/TestResults/coverage.info
Your formatting is off. Use the dash only on the first line, like so:
- uses: actions/checkout#v2
- name: Cache Nuget
uses: actions/cache#v1
If you also prefix the last line with a dash (-), then GitHub thinks the name is a separate step and it doesn't know what to do with it. Not using a dash, however, means the uses belongs to the same step as name.
Currently, I got some problems when I try to write the YAML file for deploying the GitHub action for KMM project. I don't know how to write the correct script (gradlew command) about testing the code of the shared module. Here's a part of my YAML file:
test_job:
name: Test
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Set up JDK 11
uses: actions/setup-java#v2
with:
java-version: '11'
distribution: 'adopt'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action#e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Restore Cache
uses: actions/cache#v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Make gradle executable
run: chmod +x ./gradlew
- name: Run Debug Tests
run: ./gradlew testDebugUnitTest --continue
- name: Upload Test Reports
if: ${{ always() }}
uses: actions/upload-artifact#v2
with:
name: test-reports
path: '**/build/reports/tests/'
You can use:
./gradlew check to run tests for all your targets
./gradlew <targetName>Test to run it for a specific target
Note that probably you'd want to specify the shared module as well, for ex: ./gradlew :shared:check
For more information you could check out: https://kotlinlang.org/docs/mpp-run-tests.html#run-tests-for-one-or-more-targets
Here is my config file.my tests work fine without mysql and successfully stop execution in that case but when running testcases with mysql it just get stuck over here.
name: CI
on: [push, pull_request ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 14.x, 15.x ]
steps:
- uses: actions/checkout#v2
- name: Shutdown Ubuntu MySQL (SUDO)
run: sudo service mysql stop
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v1
with:
node-version: ${{ matrix.node-version }}
- name: Set up MySQL 8.0
uses: mirromutth/mysql-action#master
with:
mysql version: 8.0
mysql database: root
mysql root password: root
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm test
- name: Cancel previous runs of this workflow
uses: styfle/cancel-workflow-action#0.6.0
with:
access_token: ${{ github.token }}
env:
CI: true