I've been trying to get github actions to do the CI part of this particular test that has been created however, I also encounter a similar error when running the test. The test works locally, so that's great. When it's solely being ran with GitHub actions, it doesn't.
I first see a warning:
WARN #wdio/mocha-framework: Unable to load spec files quite likely because they rely on `browser` object that is not fully initialised.
which eventually becomes an error on the test:
ERROR #wdio/runner: Error: Unable to load spec files quite likely because they rely on `browser` object that is not fully initialised.
What else do I need to do in GitHub actions to get this to run the test and pass as it should?
The yml file has been set up to do the following:
name: CI
on: [push, pull_request]
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Install Chromium
run: sudo apt-get install chromium-browser
- uses: actions/setup-node#v1
with:
node-version: 18
- name: Install
run: npm install
- name: Test
run: npx wdio wdio.git.js
- uses: actions/upload-artifact#v1
if: failure()
with:
name: logs
path: logs
You can also see the repo here: https://github.com/saucechaffe/sauceonsauceoff
I've attempted to change the yml file to configure different things, I've read that it isn't necessary to build chrome on the ubuntu machine but on some hands it is so I've left it in there for now. I've also attempted this: How to run WebdriverIO tests with GitHub Actions? but just keep getting stuck in the process.
Resolved this by removing a line of code that required chrome webdriver as it was causing the error and wasn't needed/being used.
Related
I'm generating a bunch of static files via getStaticPaths and it appears there are too many of them.
My GitHub workflow looks like this:
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- run: npm install
- run: npm run lint
- run: npm run build
- uses: actions-hub/gcloud#master
env:
PROJECT_ID: ***
APPLICATION_CREDENTIALS: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}}
with:
args: app deploy app.yaml --project ***
which gives me the ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: This deployment has too many files. New versions are limited to 10000 files for this app. error.
I've tried splitting those static files into some directories by adding one nesting level, but it feels like this is a temporary solution.
How can I overcome this limit? Maybe I should store static files in some different place?
I have a single Github repository for both server and frontend. The directory structure looks like:
root
|- frontend
|- server (Express App)
Github Action:
name: Node.js CI
on:
push:
branches: [ main ]
jobs:
build:
runs-on: self-hosted
strategy:
matrix:
node-version: [14.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout#v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
working-directory: './server'
- run: npm run start
working-directory: './server'
I only have a single job to build the Express server (and not the frontend yet) so I set the working-directory to ./server. However, I still get an error:
Dependencies lock file is not found in /home/{username}/runners.../repository_name. Supported file patterns: package-lock.json,yarn.lock
So apparently it's not trying to run in .../reposirtoy_name/server.
I'm just trying to build both server and frontend in single Github action.
There might be a chance that your problem is specifically with "uses: actions/setup-node". They mention in the docs that if you have multiple lock files or a lock file(s) in a directory that is not the root
In my case I had a single project with nested projects/dir. In my GitHub actions I wanted to run npm test on the nested project/dir so I had to specify to use my package.json inside the specific sub-directory. Double check to see that you are specifying the right directories with cache-dependency-path.
Specified here
https://github.com/actions/setup-node#caching-packages-dependencies
Try out this solution. It worked in my case.
In the build insert the default working directory
build:
runs-on: self-hosted
defaults:
run:
working-directory: ./server/
strategy:
matrix:
node-version: [14.x]
Then include cache dependency path. This should be the location of your package-lock.json file
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: './server/package-lock.json'
tldr
Make sure your checkout repo step is BEFORE setup node step, if using cache property with actions/setup-node#v3.
For me, it was caused by cache property on actions/setup-node#v3.
Without it - everything worked fine.
With it - failed. Reason is, it uses as cache key the package-lock.json (or yarn.lock) file.
See: https://github.com/actions/setup-node
My checkout repo step (actions/checkout#v2) was AFTER the setup node step, so it didn't find the package-lock.json file - because it wasn't checked out yet.
I have this workflow.yaml for github actions:
name: CI/CD
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14]
steps:
- name: Checkout repository
uses: actions/checkout#v2
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v2
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
uses: borales/actions-yarn#v2.0.0
with:
cmd: install --ignore-engines
- name: Run linters
uses: borales/actions-yarn#v2.0.0
with:
cmd: lint:prettier
- name: Run cypress
uses: cypress-io/github-action#v2
with:
build: npm run build
start: npm start
- name: Build
uses: borales/actions-yarn#v2.0.0
with:
cmd: build
Then it runs, on run cypress occurs an error:
error An unexpected error occurred: "EACCES: permission denied, unlink
'/home/runner/work/gos_front/gos_front/node_modules/.yarn-integrity'"
.
Before that I add cypress run all was right. I tried to add sudo but it not helped. I use yarn.
cypress-io/github-action tries to install dependencies as well and runs into an access issue. The problem is the way your node_modules folder is created.
I ran into this when using Docker, mapping node_modules from inside the docker image to the outside. This is a known issue.
You use borales/actions-yarn. This is an outdated package, that probably does something similar. You should instead use yarn directly. From their readme:
Please keep in mind that this Action was originally written for GitHub Actions beta (when Docker was the only way of doing things). Consider using actions/setup-node to work with Yarn. This repository will be mostly supporting the existing flows.
I am new to Gatsby and just tried a GH Actions workflow for my site today. I see this error at the build stage:
error "gatsby-source-github-api" threw an error while running the
sourceNodes lifecycle: token is undefined
I am using this to pull all repos on my Github into the site.
What I have tried so far:
Checked the Github personal access token
the build is working locally
Versions:
"gatsby-source-github-api": "^0.2.1" "gatsby": "^2.26.1"
This is my node.js.yml GH Actions workflow file:
name: Node.js CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [13.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout#v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build
PS: I have used a .env file to hold the value of the token that the plugin 'gatsby-source-github-api' requires. And it is in my .gitignore file. So which means it is not sent to GH and hence can't find it?
So that was it -- the .env file which wasn't being pushed to Github.
So I needed to make the token available to the GH Action build somehow.
I tried the action SpicyPizza/create-envfile#v1. It isn't supported by Github but seemed to do the job. It creates a .env file at build with the keys you provide it.
You could also create a .env file manually. See thread.
I'm having an issue with uploading artifacts to github from within a workflow.
This is my yaml file:
on:
push:
branches:
- master
jobs:
build:
name: build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Install robotframework and dependencies
run: |
pip install selenium
pip install robotframework
pip install robotframework-seleniumlibrary
pip install robotframework-imaplibrary
pip install robotframework-httplibrary
pip install robotframework-requests
- name: Download and install chromedriver
run: |
wget http://chromedriver.storage.googleapis.com/77.0.3865.10/chromedriver_linux64.zip
sudo unzip chromedriver_linux64.zip -d /usr/local/bin
export CHROME_BIN=chromium-browser
- name: Run robot tests
run: |
cd robot/tests
python -m robot -i ready bookingform.robot
- name: publish test results
uses: actions/upload-artifact#v1
with:
name: report
path: report.html
- name: clean up stuff
run: |
history
pwd
Everything runs fine up until "publish test results", at which point nothing is written to the logs and no artifacts are uploaded. If I view the workflow log, there is a grey icon alongside that step (not the usual check or red x), so I'm really baffled at what could be happening. I added arbitrary stuff to the "clean up stuff" step just to test what happens, and that step isn't run either.
I've tried messing around with the path, thinking that it could be related to the path being invalid or something, but that hasn't helped. No matter what I add near the bottom of that file, the same behaviour occurs.
I have tried running another workflow file which uploads artifacts and that ran fine, the logs showed that the upload action was invoked and that the artifact was saved, but I don't see anything like that when my yaml file is used.
Each job step resets the working path to GITHUB_WORKSPACE, which will be the root of your repository after actions/checkout runs.
The upload-artifact action most likely can't find report.html because it's no longer in the correct directory.
Try changing the path as follows:
- name: publish test results
uses: actions/upload-artifact#v1
with:
name: report
path: robot/tests/report.html
There is also a working-directory that you can set for a step. However, it seems to be incompatible with uses for actions. It can only apply to run script steps.
Using working-directory with uses will NOT work:
- name: publish test results
working-directory: robot/tests
uses: actions/upload-artifact#v1
with:
name: report
path: report.html
Using working-directory with run will work:
- name: print test results
working-directory: robot/tests
run: cat report.html
Tasks are not executed, if previous Tasks have failed; see Status check functions.
Using if: ${{ failure() }} a Task only executes, if the previous Task has failed.
So for me it solved the Problem to add if: ${{ failure() }}:
- name: Upload Cypress Artifacts
if: ${{ failure() }}
uses: actions/upload-artifact#v3
with:
path: ./cypress