Github Actions: cannot find input file: Makefile.in - github

I'm trying to use Github Actions to compile a project, but I always get the error cannot find input file: Makefile.in. I don't get the error when compiling locally on my computer.
Here is my code:
name: C/C++ CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout#v3
- run: chmod +rwx ./configure
- name: Configure
run: ./configure CC="gcc"
- name: make
run: make
It seems that Github is not able to create new files during a workflow run. I've also noticed that if I try to create a folder (eg. mkdir build), the folder isn't created (running cd build on the folder fails). Does anyone know how to work around this issue?

Related

Github Actions: warning about set-output, but not using it

I am using a GitHub actions to "build" a python app (running linting, code coverage, and tests). At the end of the action I get the following warning:
1 warning
build
The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
but my python-app.yml does not use set-output:
name: Python application
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout#v3
- name: Set up Python 3.10
uses: actions/setup-python#v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint pytest pytest-cov
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with pylint
run: |
pylint src
continue-on-error: false
- name: Test with pytest
run: |
pytest
- name: pytest coverage
run:
pytest --cov=./ --cov-report=xml:tests/coverage.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action#v3
and so I am not sure how to amend my .yml in order to make it compliant for the future.
In your workflow, there may be indirect dependencies on actions that have yet not been updated for GITHUB_OUTPUT against the set-output deprecation.
You need to check all the actions in your workflow one by one for version updates with the set-output fix.
In your case, visiting https://github.com/actions/setup-python reveals that there's a new version available. And, searching for the set-output string in the repo results in relevant references e.g. issues, commit, etc. For example, this issue (https://github.com/actions/setup-python/issues/578) verifies that it has been fixed in #v4.
So, as of now, using #v4 should fix it i.e.:
- uses: actions/setup-python#v4
The actions are being updated gradually. Hopefully, all of them will be updated soon and we won't be seeing that warning anymore.

actions not using default working directory

I have a repository with some subdirectories. One of the subdirectory is called gradle-specific which is the gradle project. I want to run ./gradlew clean build using github actions. My yaml file looks as follows:
name: Java CI with Gradle
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ./gradle-specific
steps:
- uses: actions/checkout#v3
- name: Set up JDK 16
uses: actions/setup-java#v3
with:
java-version: '16'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action#67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: clean build
but error logs indicate that the build is happening in the root folder itself:
Error: Error: Cannot locate a Gradle wrapper properties file at '/home/runner/work/service-commons/service-commons/gradle/wrapper/gradle-wrapper.properties'. Specify 'gradle-version' or 'gradle-executable' for projects without Gradle wrapper configured.
where service-commons is my repository name
I tried specifying the working directory without relative path, with relative path, specifying globally. I am following https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_iddefaultsrun to configure the same

Working directory is not working in my Github action

I'm starting to use Github actions. When I ran the process in my Ubuntu server, one of the config options was to select the work folder, by default, I leave _work. But previously, I had my repository in another folder.
So, I'm trying to add a specific value for working-directory to my yml, file but is not using the value in the build process.
YML File:
# 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: Node.js CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
defaults:
run:
working-directory: /../../../../var/www/mysite.com
jobs:
deployment:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout#v3
- name: Use Node.js
uses: actions/setup-node#v3
with:
node-version: '14.x'
- name: Install dependencies
run: yarn
- name: Build
run: yarn build
- name: Restart server application
run: pm2 restart pm2_script.json
The process ran ok, but is doing all the process (checkout, build, etc) inside _work and not inside working-directory
What I'm doing wrong?
Thanks!!

How to replace a API key with a Secret in code during Github Actions Job?

I usually hide my API key in an XML file and use .gitignore along with getString() to retrieve my API key.
I'm trying to use Github Actions to automate Gradle build and Release of debug apk's. Due to the XML file not being uploaded to the repo, it obviously fails.
Is there any way to store my key in Github Secrets and then replace the code with the secret?
Current code: headers["token"]= getString(R.string.token)
Replaced code in Github actions server : headers["token"]="MY_API_KEY_FROM_SECRETS"
Here's my YAML file that I was using:
name: Gradle build test and release
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
#I'd like to replace the api key here in code from secrets
- name: Make Gradle executable
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Build Debug APK
run: ./gradlew assembleDebug
- name: Releasing using Hub
uses: ShaunLWM/action-release-debugapk#master
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
APP_FOLDER: app
RELEASE_TITLE: New Build
BODY: github.event.head_commit.message
prerelease: true
Sure, this is possible. You haven't said what file you'd like modified, but this should be easy enough to do with a one-liner (replacing FILENAME with your config file name):
- run: perl -pi -e 's/getString\(R\.string\.token\)/"$ENV{TOKEN}"/' FILENAME
env:
TOKEN: ${{ secrets.TOKEN }}
If you prefer Ruby or some other scripting language, you can use that instead. You could also use sed, but I prefer this approach because it means that the value is never available in ps output (even if this is a locked down VM).

github action: run a test file on pull request

I want to run a test file when someone sends a pull request.
This is my action.yml file.
name: "GitHub Actions Test"
on:
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
steps:
# - uses: actions/checkout#v1
- name: 'Install Node'
uses: actions/setup-node#v1
- name: Install mocha
run: npm install -g mocha
- name: Install dependencies
run: npm install
- name: "Run Test"
run: mocha test-mocha.test.js
but when running the test from github, I got the following error:
Error: No test files found: "test-mocha.test.js"
I wonder something is wrong on the last line of my yml file.
how to fix this?
This is because you've commented out the line that checks out your code:
# - uses: actions/checkout#v1 # Remove the comment from this line
By default, your code is not checked out in the workflow's directory. As such, you have to use the Checkout GitHub Action to check out your code.
From the README:
This action checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it.