In order for my project to run i need to run a script that building my Cmake folder, so when i do Ci with git action i need to run this :
cd app/src/main/cpp
than
sh build_cmake.sh
I have something like that :
- name: Check out repository code
uses: actions/checkout#v3
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- name: Setting up Cmake
run: |
cd app/src/main/cpp - name: Setting up Cmake
- name: running script
run: |
sh build_cmake.sh
obviously that is not working,
how my goal can be achieve?
You can put both commands in one run:
- name: running script
run: |
cd app/src/main/cpp
sh build_cmake.sh
Another way to solve is to use working-directory (https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun) property:
- name: running script
working-directory: app/src/main/cpp
run: |
sh build_cmake.sh
Related
I set up a simple CI work in Github Action for my Android project (Kotlin) that would init unit testing before merging with the master (main) branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout#v3
# Setup JAVA
- name: set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
# Execute unit tests
- name: Unit Test
run: chmod +x ./gradlew test
But whenever i push any commit into directory, i receive next error which fails Unit tests and block merging:
Run chmod +x ./gradlew test
chmod +x ./gradlew test
shell: /usr/bin/bash -e {0}
env:
JAVA_HOME_8.0.342_x64: /opt/hostedtoolcache/jdk/8.0.342/x64
JAVA_HOME: /opt/hostedtoolcache/jdk/8.0.342/x64
JAVA_HOME_8_0_342_X64: /opt/hostedtoolcache/jdk/8.0.342/x64
chmod: cannot access 'test': No such file or directory
Error: Process completed with exit code 1.
I tried to manually set up a directory with tests using working-directory: app/src/ but it throws the same type of error.
What I am doing wrong?
Will provide more info on request. Thanks in advance.
ANSWER: To run unit test in pre-merge, you need to set the correct directory, with the working-directory:, In my case it's :
./app/src/
Changes in workflow .yaml
# List all files (Optional)
- name: ls
run: ls -alrth
- name: add permisiion to gradlew
run: chmod +x ./gradlew
# Execute unit tests
- name: run unit tests
working-directory: ./app/src/
run: chmod +x ./test
I would make multiple RUN commands to ensure where I am and what is in the current folder:
run: pwd
run: ls -alrth
run: chmod +x ./gradlew
run: chmod +x ./test
AS noted by the OP GremlinShX, a working-directory: ./app/src was missing.
I'm trying to setup CI on Gitlab. I've got a problem. Looks like runner is working well but each time I try to run pipeline it fails with following error :
Running with gitlab-runner 14.4.0 (4b9e985a)
on local-runner g_SbFiLZ
Resolving secrets
00:00
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:00
Running on GU33...
Getting source from Git repository
00:02
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in C:/Users/xxx/GitLab-Runner/builds/g_SbFiLZ/0/xxx/xxx/.git/
Checking out f4fb6ec9 as main...
git-lfs/2.11.0 (GitHub; windows amd64; go 1.14.2; git 48b28d97)
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:01
$ gem install bundler
gem : The term 'gem' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the s
pelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\WINDOWS\TEMP\build_script461193448\script.ps1:225 char:1
+ gem install bundler
+ ~~~
+ CategoryInfo : ObjectNotFound: (gem:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit status 1
I have Ruby installed and setup correctly. I can run gem commands locally. Runner is also set locally so I really dont understand the issue. Here's my gitlab-ci.yml :
stages:
- prepare
- build
- test
- ui-test
variables:
LC_ALL: "en_US.UTF-8"
LANG: "en_US.UTF-8"
.setup_bundler: &setup_bundler |
gem install bundler
bundle config
bundle install
.setup: &setup
- *setup_bundler
prepare_project:
stage: prepare
script:
*setup
cache:
key:
files:
- Gemfile.lock
paths:
- vendor
artifacts:
name: "Bundle_${CI_BUILD_NAME}_${CI_COMMIT_REF_NAME}_${CI_BUILD_ID}"
expire_in: 1 day
paths:
- vendor
when: always
when: on_success
tags:
- android
build:
stage: build
script:
- bundle exec fastlane build
dependencies:
- prepare_project
tags:
- android
test:
stage: test
script:
- bundle exec fastlane tests
dependencies:
- prepare_project
tags:
- android
ui-test:
stage: ui-test
script:
- bundle exec fastlane ui_tests
dependencies:
- prepare_project
tags:
- android
Any ideas, pelase ?
It's likely that when you're running gem to debug, you're running it with a different user than gitlab-runner, which is the default gitlab-runner user. Check the PATH setup of your gitlab-runner user, and ensure that gem is on the path.
I am trying to upload an apk to firebase using github action.
I have commented out the code analysis and tests to make the action run faster so as to try and resolve the issue. I have also tried to upload an app bundle, I get the same response.
Here is the github action configuration.
name: Deploy app bundle to firebase
on:
push:
branches:
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-java#v1
with:
java-version: '12.x'
- uses: subosito/flutter-action#v1 # Setup flutter environment
with:
flutter-version: '2.5.0'
- run: flutter pub get
- run: flutter pub run build_runner build --delete-conflicting-outputs
- name: Create env file
run: |
cat << EOF > .env
STAGING_API_BASE_URL="${{ secrets.STAGING_API_BASE_URL }}"
PROD_API_BASE_URL="${{ secrets.PROD_API_BASE_URL }}"
BASE_PATH="${{ secrets.BASE_PATH }}"
EOF
# - run: flutter format --set-exit-if-changed # - run: flutter format --set-exit-if-changed .
#- run: flutter analyze # Analyze the project's Dart code. This causes job to exit
#- name: Run flutter analyze
# run: |
# chmod +x ./flutter_analyze.sh
# ./flutter_analyze.sh
#- run: flutter test # Run Flutter unit tests for the current project.
- name: Build Gradle
run: flutter build apk --debug
- uses: actions/checkout#v2 #This uploads artifacts from your workflow
with:
name: debug-apk
path: build/app/outputs/flutter-apk/app-debug.apk
- run: ls build/app/outputs/flutter-apk
- name: Upload artifact to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action#v1.3.2
with:
appId: ${{secrets.FIREBASE_APP_ID}}
token: ${{secrets.FIREBASE_TOKEN}}
groups: testers
file: build/app/outputs/flutter-apk/app-debug.apk
When I run the workflow I get the following error:
You can use this script to find your built apk path:
run: |
echo "Find build artifacts"
apkPath=$(find app -name "*.apk" | head -1)
echo "Found apk at $apkPath"
if [[ -z ${apkPath} ]]
then
echo "No apks were found, skip publishing to App Distribution"
else
echo "Publishing $apkPath to App Center"
#publish your apk by using $apkPath
fi
it scans all agent files and finds apk file.
use
wzieba/Firebase-Distribution-Github-Action#v1.3.3
I had made a mistake on this line
- uses: actions/upload-artifact #This uploads artifacts from your workflow
The comment is correct but the action is wrong.
I should have used actions/upload-artifact https://github.com/wzieba/Firebase-Distribution-Github-Action/issues/51
I am using workflow on GithubActions but getting the following error:
chmod: cannot access './gradlew': No such file or directory
Error: Process completed with exit code 1.
Following is my workflow.yml file
name: Android CI
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew build
I tried you change chmod command in a different way but non of execution succeed, but same workflow on my other project is working file i don't know whats the issue, Any help highly appreciated. Thanks
I tried to change chmod command in a different way
That wouldn't change the fact the file itself (gradlew) seems to be missing.
I would check if it is anywhere (run: find / -type f -name "gradlew"), considering the actions/setup-java is supposed to include Gradle.
That would be just for testing, as a first step:
- name: Look for gradlew
run: find / -type f -name "gradlew"
- name: Change wrapper permissions
...
If it is in the $PATH, this issue suggests:
I changed
"./gradle build" to "gradle build" in Build with Gradle step.
That solved the issue. (see gradle-publish.yml)
Instead of using ./gradlew, try using gradle. This worked for me.
This solution here helped me solve the same problem. You just have to change the gradlew file permission using this code: Run this on the terminal
git update-index --chmod=+x gradlew
git commit -m "Make gradlew executable"
I also removed chmod +x from my workflow.yml file after changing the gradlew file permissions
I have faced the same issue and I found someone change it to
name: gradlew
run: gradle
enter image description here
with removing "./" and "w"
and worked for me
It's possible that you don't initialise wrapper.
You can try clone your repository from scratch and the exetuce ./gradlew build command. If it's failed. Try use the
gradle wrapper
This command init your wrapper and you can see which files was generated and required for ./gradlew
Finally, You have two options:
Run gradle wrapper locally and push required files
or
Add extra step to init wrapper during the workflow
...
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Init gradle wrapper
run: gradle wrapper
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Build with Gradle wrapper
run: ./gradlew build
I'm implementing APK distribution with Firebase App Distribution Using Circle CI and In which I have a workflow with 2 jobs, One job build the APK and the second one deploy it on Firebase App Distribution.
version: 2.1
jobs:
build:
working_directory: ~/code
docker:
- image: circleci/android:api-29
environment:
JVM_OPTS: -Xmx2g
GRADLE_OPTS: '-Dkotlin.compiler.execution.strategy="in-process"'
steps:
- checkout
- run:
name: Create keystore.jks
command: echo $RELEASE_KEY_BASE64 | base64 --decode > $RELEASE_KEY_STORE
- run:
name: Create keystore.properties
command: printf 'releaseKeyAlias=%s\nreleaseKeyPassword=%s\nreleaseKeyStore=%s\nreleaseStorePassword=%s' $RELEASE_KEY_ALIAS $RELEASE_KEY_PASSWORD $RELEASE_KEY_STORE $RELEASE_KEY_PASSWORD > keystore.properties
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Download Dependencies
command: ./gradlew androidDependencies
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Run Tests
command: ./gradlew lint test
- run:
name: Run UnitTest
command: ./gradlew test
- store_artifacts:
path: app/build/reports
destination: reports
- store_test_results:
path: app/build/test-results
- run:
name: Initial build
command: ./gradlew clean assembleRelease --no-daemon --stacktrace
- store_artifacts:
path: app/build/outputs/apk/
destination: apks/
deploy:
docker:
- image: circleci/ruby:2.4-node
working_directory: ~/code
shell: /bin/bash --login -o pipefail
steps:
- checkout
- run:
name: Install Firebase CLI
command: curl -sL https://firebase.tools | bash
- run:
name: Distribute APK to Firebase
command: firebase appdistribution:distribute "/home/circleci/code/app/build/outputs/apk/release/app-release.apk" --app $FIREBASE_APP_ID --token $FIREBASE_TOKEN --release-notes "Test Release Note" --groups $FIREBASE_TEST_GROUP --debug
workflows:
version: 2.0
build-deploy:
jobs:
- build:
- deploy:
requires:
- build
And When I access the APK in deploy job which was generated in build Job, I got the below error.
Error: File /home/circleci/code/app/build/outputs/apk/release/app-release.apk does not exist: verify that file points to a distribution.
But The same code is working in a single job.
Is there any way to get the file access to another job?
I know I was able to share this workspace between the build and deliver
executors:
my-xecutor:
docker:
- image: circleci/android:api-29-node
working_directory: ~/repo/MYAPP
jobs:
build:
executor: my-xecutor
environment:
JVM_OPTS: -Xmx4G
steps:
# Clone the repo
- checkout:
path: ~/repo
# Build and test, using cached assets if possible
- restore_cache: &CACHE_KEY
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
# build.sh is not shown here too complex and app specific
- run:
name: Build and test
command: ../scripts/build.sh
- save_cache:
<<: *CACHE_KEY
paths:
- ~/.gradle
# Make test results show up in the CircleCI build dashboard
- run:
name: Save test results
command: |
mkdir -p ~/junit/
find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/junit/ \;
when: always
- store_test_results:
path: ~/junit
- store_artifacts:
path: ~/junit
- persist_to_workspace:
root: ~/repo
paths:
- scripts
- MYAPP/app/build.gradle
- MYAPP/app/build/outputs/apk/release.notes.txt
- MYAPP/app/build/outputs/apk/*/*/
- run:
command: |
ls -l app/build/outputs/apk/*/*/
- run:
command: cat /sys/fs/cgroup/memory/memory.max_usage_in_bytes
when: always
deliver:
executor: my-xecutor
steps:
- attach_workspace:
at: ./
- run:
command: |
ls -lR .
- run:
name: Download appcenter
command: |
sudo npm install appcenter-cli -g
# then run your upload to appcenter cli command and use the path
# MYAPP/app/build/outputs/apk/{debug|release}/app_file_name.apk
# I also attached release notes to upload