env:
APP_PATH: ${{ github.workspace }}/MyApp/Build/Applications/MyApp.app
jobs:
build:
runs-on: macos-latest
steps:
- name: Upload app
uses: svenstaro/upload-release-action#v2
with:
file: ${APP_PATH}
This fails with:
Error: ENOENT: no such file or directory, stat '${APP_PATH}'
The docs say to use, e.g. $DAY_OF_WEEK, but it doesn't work. I've tried $APP_PATH, ${APP_PATH}, and ${{APP_PATH}}.
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?
I would like to create a CI pipeline with GitHub Action but I have problems. The front end of the project is developed in Vue 3 and uses vitest to run the tests. It's in a folder called "WEB" in the root directory. So I would like to run my tests at each commit in the master branch but it returns this error:
Error: .github#L1
each step must define a `uses` or `run` key
I used the preexisting "Node.js" template and just added the "working-directory" property to specify the "WEB" folder.
Here is my ".yml" file
name: Runs frontend tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout#v3
- name: Use Node.js ${{ matrix.node-version }}
working-directory: ./WEB
uses: actions/setup-node#v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Execute Unit tests
- run: npm ci
- run: npm run test
When you add a - it add an element at the steps array:
You should do it like this:
- name: Execute Unit tests
run: |
npm ci
npm run test
I would like to create a GitHub Workflow that builds a C++ application using emscripten and cmake, and deploys it to GitHub Pages. My Workflow job looks like this.
environment:
name: github-pages
url: ${{steps.deployment.outputs.page_url}}
runs-on: ubuntu-latest
container:
image: emscripten/emsdk
steps:
- uses: actions/checkout#v3
- run: cmake -B $GITHUB_WORKSPACE/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DEMSCRIPTEN=ON
- run: cmake --build $GITHUB_WORKSPACE/build --config ${{env.BUILD_TYPE}}
# actions/upload-pages-artifact uses this directory, but it doesn't exist in the image
- run: mkdir -p ${{runner.temp}}
- uses: actions/configure-pages#v1
- uses: actions/upload-pages-artifact#v1
with:
path: $GITHUB_WORKSPACE/build
- id: deployment
uses: actions/deploy-pages#v1
upload-pages-artifact runs tar and lists all the files to be deployed in the log. When running upload-artifact the log reads Warning: No files were found with the provided path: /__w/_temp/artifact.tar. No artifacts will be uploaded..
Note that the path in the warning is different from the one provided as a parameter to upload-artifact (path: /home/runner/work/_temp/artifact.tar).
upload-pages-artifact works as expected when running without the emscripten container.
I would have to either get upload-pages-artifact working inside the container, or somehow share the build with a second job running outside the container.
Split up the job into two jobs, one for building and one for deploying. Use actions/upload-artifact and actions/download-artifact to pass the build from one job to the next. Don't use $GITHUB_WORKSPACE, as it might not point to the right directory in your image.
jobs:
build:
runs-on: ubuntu-latest
container:
image: emscripten/emsdk
steps:
- uses: actions/checkout#v3
- run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DEMSCRIPTEN=ON
- run: cmake --build build --config ${{env.BUILD_TYPE}}
- uses: actions/upload-artifact#master
with:
name: page
path: build
if-no-files-found: error
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: github-pages
url: ${{steps.deployment.outputs.page_url}}
steps:
- uses: actions/download-artifact#master
with:
name: page
path: .
- uses: actions/configure-pages#v1
- uses: actions/upload-pages-artifact#v1
with:
path: .
- id: deployment
uses: actions/deploy-pages#main
I would like to execute a github action in a sub-directory of my project because my Github repo contains 2 applications (front/back) and I need to test the front. (see below)
my-project
├─ api/
│ └─ ...
└─ front-app/
└─ (node-js application I want to run the tests for)
I want to execute only the tests for the front-app running on svelte (node-js)
The tests fails because they run in the project directory instead of the front-app/ one.
However I already implemented :
# Just after `on: push / pull_request`
defaults:
run:
working-directory: ./front-app/
# And before `jobs`
And I still get the error :
Run actions/setup-node#v3
Found in cache # /opt/hostedtoolcache/node/16.16.0/x64
/opt/hostedtoolcache/node/16.16.0/x64/bin/npm config get cache
/home/runner/.npm
Error: Dependencies lock file is not found in /home/runner/work/my-project/my-project. Supported file patterns: package-lock.json,npm-shrinkwrap.json,yarn.lock
The file is define as :
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Tests for front-app
on:
push:
branches: [ "main" ]
paths: ["front-app/**"]
pull_request:
branches: [ "main" ]
paths: ["front-app/**"]
defaults:
run:
working-directory: ./front-app/
jobs:
test-front-app:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x]
steps:
- uses: actions/checkout#v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v3 # <-- I think the error occurs here
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci # <-- This is not executed - The error occurs before
- run: npm run build --if-present
- run: npm test
So, I found the solution in the documentation here by adding cache-dependency-path: with the path of the package-lock.json (see below)
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: 'front-app/package-lock.json'
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