I am new to tox and GitHub actions and I'm facing a problem. tox testenv commands don't seem to run on a self-hosted server. This is the result of pushing a commit to the github repository:
tox
...
___________________________________ summary ____________________________________
congratulations :)
however, expected result should look like this:
tox
...
============================== 1 passed in 0.17s ==============================
___________________________________ summary ___________________________________
py310: commands succeeded
congratulations :)
my tox.ini file:
[tox]
minversion = 3.10
envlist = py310
isolated_build = true
[testenv]
setenv =
PYTHONPATH = {toxinidir}
deps =
-r{toxinidir}/requirements_dev.txt
commands =
pytest --basetemp={envtmpdir}
github workflows file
name: Tests
on:
- push
- pull_request
jobs:
test:
runs-on: self-hosted
strategy:
matrix:
python-version: ['3.10.6']
steps:
- uses: actions/checkout#v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python#v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Test with tox
run: |
tox
however, the code above works properly on a virtual machine hosted by GitHub. (runs-on: ubuntu-latest)
My server runs on Ubuntu 20.04.4 LTS.
Is there anything I am doing wrong, how do i fix that?
Ok, I managed to fix that issue by adding
[gh-actions]
python =
3.10: py310
to the tox.ini file
Related
I'm trying to set my Github secrets as env variables via Actions but for some reasons they aren't being set (Using Ubuntu 22.04.1 LTS).
name: My app
on:
push:
branches: [ "main" ]
env:
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }}
JWT_REFRESH_SECRET: ${{ secrets.JWT_REFRESH_SECRET }}
MONGO_CONNECTION_STRING: ${{ secrets.MONGO_CONNECTION_STRING }}
PLAI_APP_URL: ${{ secrets.APP_URL }}
SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }}
permissions:
contents: read
jobs:
build:
runs-on: self-hosted
steps:
- name: check out latest repo
uses: actions/checkout#v3
with:
ref: main
- 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 -r requirements.txt
Workflow runs successfully without errors but when I check my variables via env they are not listed. Any idea what I'm doing wrong?
You could follow the same idea as in "Managing secrets in an open-sourced flutter web app" from Mahesh Jamdade:
encode your confidential file to base64 and store the encoded output to GitHub secrets.
In your GitHub workflow decode the encrypted secret and convert it back to a file and then run your build scripts.
You can see an example in "How to access secrets when using flutter web with github actions".
Example workflow: maheshmnj/vocabhub .github/workflows/firebase-hosting-merge.yml.
I created a workflow for my Python repo as follows:
name: Python package
on: [push, pull_request]
jobs:
build:
runs-on: [ubuntu-latest, macos-latest]
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout#v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python#v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest semver
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings.
flake8 . --count --exit-zero --max-complexity=10 --ignore=E501 --statistics
- name: Test with pytest
run: |
pytest
Unfortunately, the action never runs and times out with the error:
This request was automatically failed because there were no enabled runners online to process the request for more than 1 days.
Did I do something silly in the configuration file?
I'm currently on a free GitHub account. Are GitHub-hosted runners available on free accounts? If so how do I enable one of those?
Turns out
runs-on: [ubuntu-latest, macos-latest]
doesn't run the action on each platforms. Instead it tries to find a runner that satisfies both conditions, i.e. running on ubuntu-latest and macos-latest which is, of course, never found.
The way to so what I originally intended is to, instead, do a two-dimensional matrix for os and python-version.
I couldn't make this workflow work, I'm always receiving this error every step must define a "uses" or "run" key, but looking at my script I don't see any issues, can someone pls help me fix this? It does not seem like a - problem as it usually is.
# This is a basic workflow to help you get started with Actions
name: Build Digital Ocean Image
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches:
- '*'
- '*/*'
- '**'
- '!master'
pull_request:
branches: [ "master" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
packages:
runs-on: ubuntu-latest
steps:
- name: Install packages
run: |
apt-get install curl -y
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install packer
apt-get install ansible -y
# 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:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout
uses: actions/checkout#v3
# Runs a single command using the runners shell
- name: Packer init
env:
DIGITALOCEAN_TOKEN=${{ secrets.DIGITALOCEAN_TOKEN }}
run: packer init
working-directory: /home/runner/work/packer-do-custom-images/demo
# Runs a set of commands using the runners shell
- name: Packer build
run: packer build .
working-directory: /home/runner/work/packer-do-custom-images/demo
The runs-on directive is missing (commented!), just add/uncomment it after the name, like:
# 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:
To fix the issue.
I would suggest to use the actionlint tool to discover error like this, as example:
> actionlint .github/workflows/test.yaml
.github/workflows/test.yaml:35:3: "runs-on" section is missing in job "build" [syntax-check]
|
35 | build:
| ^~~~~~
UPDATE:
As side notes also the env variable as issue: you should use : instead of = like:
- name: Packer init
env:
DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}
I need some help I have a gradle project within the IntelliJ IDEA and I'm trying to automate gradle with github using the github actions. My .yml file for the github action contains
name: CI - build and test
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up JDK 11
uses: actions/setup-java#v2
with:
java-version: '11'
distribution: 'adopt'
- name: Grant execute permission for gradlew
working-directory: ./project
run: chmod +x ./gradlew
- name: Build
working-directory: ./project
run: ./gradlew build
- name: Test
working-directory: ./project
run: ./gradlew test
- name: Update Website
working-directory: ./project
run: ./gradlew deployReports
The error is coming from the final step - name: Update Website working-directory: ./project run: ./gradlew deployReports
here is the function for deployReports located within my build.gradle file
task deployReports (dependsOn: 'copyWebsite'){
group = "Reporting"
description 'Copies reports to the website repo and pushes to github'
doLast{
def pagesDir = "$buildDir/gh-pages"
exec{
workingDir = 'build/gh-pages'
commandLine = ['git', 'add', '.']
}
exec{
workingDir = 'build/gh-pages'
commandLine = ['git', 'commit', '-m', 'Updating-webpages']
}
exec{
workingDir = 'build/gh-pages'
commandLine = ['git', 'push']
}
}
}
The error is coming from this line commandLine = ['git', 'commit', '-m', 'Updating-webpages']
I'm unsure of how to fix this because git is installed correctly and I can still commit and push myself from the terminal. any insight would be great!
The simplest solution is the clone the branch through GitHub (Using a terminal). otherwise, setups git in this dir so you are able to solve this.
This happens because of the system not finding any git commands here and unable to locate git that's why it is happening
I am using Pylint GitHub action.
Every time I push a new commit all of the builds fail. (except sometimes I get an error like "operation canceled")
This is what my GitHub action file looks like:
name: Pylint
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout#v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python#v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Analysing the code with pylint
run: |
pylint choam
You can use pylint-exit to determine what that means.
pip install pylint-exit
If you execute it, you get the following:
(exit 14) || pylint-exit $?
The following messages were raised:
- error message issued
- warning message issued
- refactor message issued
No fatal messages detected. Exiting gracefully...
I would assume, it's not really an error