I am writing workflows for my repository, and I want to run test cases whenever there is a code push.
Here is the code snippet from .yml file:
- name: Run cypress test
with:
env: true
env:
username: ${{secrets.CYPRESS_USERNAME}}
password: ${{secrets.CYPRESS_PASSWORD}}
run: npm run cy:test --env fileConfig=production, username=$username, password=$password
continue-on-error: false
Snippet from JSON :
{
"env": {
"userId": "1",
"environment": "production",
"baseUrl": " base URL"
}
}
So, I want to pass the username and password along with the configfile in the cypress run mand so that they can be set as the env variable because I am using username and password for my login test module.
With the above code i am getting error :
The workflow is not valid. .github/workflows/main.yml (Line: 43, Col: 9): Unexpected value 'run' .github/workflows/main.yml (Line: 36, Col: 9): Required property is missing: uses
Thanks :)
I am writing workflows for my repository, and I want to run test cases whenever there is a code push.
Here is the code snippet from .yml file:
- name: Run cypress test
with:
env: true
env:
username: ${{secrets.CYPRESS_USERNAME}}
password: ${{secrets.CYPRESS_PASSWORD}}
run: npm run cy:test --env fileConfig=production, username=$username, password=$password
continue-on-error: false
Snippet from JSON :
{
"env": {
"userId": "1",
"environment": "production",
"baseUrl": " base URL"
}
}
So, I want to pass the username and password along with the configfile in the cypress run mand so that they can be set as the env variable because I am using username and password for my login test module.
With the above code i am getting error :
The workflow is not valid. .github/workflows/main.yml (Line: 43, Col: 9): Unexpected value 'run' .github/workflows/main.yml (Line: 36, Col: 9): Required property is missing: uses
Thanks :)
Share Improve this question asked Jun 24, 2021 at 19:32 Nitika GahlawatNitika Gahlawat 631 silver badge14 bronze badges 3-
I think the problem is not in the cypress run mand, but in that you're missing
uses
property in the YAML file. Perhaps this will help github./cypress-io/github-action – pavelsaman Commented Jun 24, 2021 at 21:11 -
I tried to use 'uses; property but it says - a step cannot have both the
uses
andrun
keys – Nitika Gahlawat Commented Jun 24, 2021 at 21:56 - Cypress has its own github actions plugin, take a look and try it docs.cypress.io/guides/continuous-integration/github-actions. – 109149 Commented Jun 27, 2021 at 10:38
1 Answer
Reset to default 4First, you need to add the env variables as empty strings on cypress.json:
{
"env": {
"userId": "1",
"environment": "production",
"baseUrl": "base URL",
"username": "",
"password": ""
}
}
In main.yml file, you need to add the CYPRESS_ prefix to the variables:
env:
CYPRESS_username: ${{secrets.CYPRESS_USERNAME}}
CYPRESS_password: ${{secrets.CYPRESS_PASSWORD}}
Also, you should use the setup that can be found on cypress docs (https://docs.cypress.io/guides/continuous-integration/github-actions#Basic-Setup), example:
name: Cypress Tests
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Install NPM dependencies, cache them correctly
# and run all Cypress tests
- name: Cypress run
uses: cypress-io/github-action@v2
with:
build: npm run build
start: npm start
env:
CYPRESS_username: ${{secrets.CYPRESS_USERNAME}}
CYPRESS_password: ${{secrets.CYPRESS_PASSWORD}}
You should also read this article: https://glebbahmutov./blog/keep-passwords-secret-in-e2e-tests/