admin管理员组文章数量:1334937
I'm currently trying to create a GitHub action where I run a Cypress test on PR changes on every PR open/reopen/update, when the PR have by target the staging branch
This is my yaml:
name: Run Cypress Tests
on:
pull_request:
branches:
- staging
types: [opened, synchronize, reopened]
jobs:
cypress:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install dependencies
run: |
yarn install
yarn serve --port 3000
- name: Run Cypress tests
run: |
npx cypress run --headless
- name: Post comment if Cypress fails
if: failure()
run: |
PR_URL=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"/${{ github.repository }}/pulls" | jq -r '.[0].url')
COMMENT="The Cypress tests failed. Please fix the issues before merging."
curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-d "{\"body\": \"$COMMENT\"}" \
"/${{ github.repository }}/issues/comments"
# Make GitHub request changes if Cypress fails
curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-d "{\"event\": \"REQUEST_CHANGES\", \"body\": \"Cypress tests have failed. Please fix the issues.\"}" \
"/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews"
This is my repo package.json:
{
"name": "front",
"version": "1.1.2",
"private": true,
"engines": {
"npm": ">=6.0.0 <9.0.0",
"node": ">=14.0.0 <17.0.0"
},
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"deploy": "aws --profile vue-deployer --region us-east-1 s3 sync ./dist s3://pichau-erp-front --delete"
},
"dependencies": {
"axios": "^0.21.1",
"bootstrap": "^5.2.0",
"buffer": "^6.0.3",
"chart.js": "^2.9.4",
"core-js": "^3.6.5",
"jquery": "^3.6.0",
"loader-utils": "^3.2.1",
"lodash": "^4.17.21",
"minimist": "^1.2.7",
"moment": "^2.29.4",
"pinia": "^2.1.7",
"popper.js": "^1.16.1",
"sockjs-client": "^1.6.1",
"sweetalert2": "^11.10.6",
"v-mask": "^2.3.0",
"v-money": "^0.8.1",
"vee-validate": "^2.2.15",
"vue": "^2.7.3",
"vue-chartjs": "^3.5.1",
"vue-jwt-decode": "^0.1.0",
"vue-notification": "^1.3.20",
"vue-router": "^3.2.0",
"vue-simple-alert": "^1.1.1",
"vuedraggable": "^2.24.3",
"vuetify": "^2.7.1",
"vuex": "^3.6.2",
"webstomp-client": "^1.2.6",
"xlsx": "^0.18.5",
"xml-js": "^1.6.11",
"yarn": "^1.22.22"
},
"devDependencies": {
"@babel/core": "^7.20.2",
"@babel/eslint-parser": "^7.19.1",
"@vue/cli-plugin-babel": "^5.0.8",
"@vue/cli-plugin-eslint": "^5.0.8",
"@vue/cli-plugin-router": "^5.0.8",
"@vue/cli-plugin-vuex": "^5.0.8",
"@vue/cli-service": "^5.0.8",
"@vue/eslint-config-prettier": "^6.0.0",
"cypress": "^13.16.0",
"eslint": "^7.32.0",
"eslint-plugin-cypress": "2.11.3",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^6.2.2",
"prettier": "2.8.8",
"sass": "~1.32.0",
"sass-loader": "^10.0.0",
"vue-cli-plugin-vuetify": "~2.4.2",
"vue-template-compiler": "^2.6.11",
"vuetify-loader": "^1.9.2"
}
}
So as can you see, I use Vue 2, Node 16 and compatible versions of Cypress. But I created 2 PRs to staging branch and nothing happened, as you can see in the image No Cypress Runs
How can I fix it? It is my first time creating an action and didn't found answers that solve my problem ?
I would like the test to run when creating the PR
I'm currently trying to create a GitHub action where I run a Cypress test on PR changes on every PR open/reopen/update, when the PR have by target the staging branch
This is my yaml:
name: Run Cypress Tests
on:
pull_request:
branches:
- staging
types: [opened, synchronize, reopened]
jobs:
cypress:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install dependencies
run: |
yarn install
yarn serve --port 3000
- name: Run Cypress tests
run: |
npx cypress run --headless
- name: Post comment if Cypress fails
if: failure()
run: |
PR_URL=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github/repos/${{ github.repository }}/pulls" | jq -r '.[0].url')
COMMENT="The Cypress tests failed. Please fix the issues before merging."
curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-d "{\"body\": \"$COMMENT\"}" \
"https://api.github/repos/${{ github.repository }}/issues/comments"
# Make GitHub request changes if Cypress fails
curl -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-d "{\"event\": \"REQUEST_CHANGES\", \"body\": \"Cypress tests have failed. Please fix the issues.\"}" \
"https://api.github/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews"
This is my repo package.json:
{
"name": "front",
"version": "1.1.2",
"private": true,
"engines": {
"npm": ">=6.0.0 <9.0.0",
"node": ">=14.0.0 <17.0.0"
},
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"deploy": "aws --profile vue-deployer --region us-east-1 s3 sync ./dist s3://pichau-erp-front --delete"
},
"dependencies": {
"axios": "^0.21.1",
"bootstrap": "^5.2.0",
"buffer": "^6.0.3",
"chart.js": "^2.9.4",
"core-js": "^3.6.5",
"jquery": "^3.6.0",
"loader-utils": "^3.2.1",
"lodash": "^4.17.21",
"minimist": "^1.2.7",
"moment": "^2.29.4",
"pinia": "^2.1.7",
"popper.js": "^1.16.1",
"sockjs-client": "^1.6.1",
"sweetalert2": "^11.10.6",
"v-mask": "^2.3.0",
"v-money": "^0.8.1",
"vee-validate": "^2.2.15",
"vue": "^2.7.3",
"vue-chartjs": "^3.5.1",
"vue-jwt-decode": "^0.1.0",
"vue-notification": "^1.3.20",
"vue-router": "^3.2.0",
"vue-simple-alert": "^1.1.1",
"vuedraggable": "^2.24.3",
"vuetify": "^2.7.1",
"vuex": "^3.6.2",
"webstomp-client": "^1.2.6",
"xlsx": "^0.18.5",
"xml-js": "^1.6.11",
"yarn": "^1.22.22"
},
"devDependencies": {
"@babel/core": "^7.20.2",
"@babel/eslint-parser": "^7.19.1",
"@vue/cli-plugin-babel": "^5.0.8",
"@vue/cli-plugin-eslint": "^5.0.8",
"@vue/cli-plugin-router": "^5.0.8",
"@vue/cli-plugin-vuex": "^5.0.8",
"@vue/cli-service": "^5.0.8",
"@vue/eslint-config-prettier": "^6.0.0",
"cypress": "^13.16.0",
"eslint": "^7.32.0",
"eslint-plugin-cypress": "2.11.3",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^6.2.2",
"prettier": "2.8.8",
"sass": "~1.32.0",
"sass-loader": "^10.0.0",
"vue-cli-plugin-vuetify": "~2.4.2",
"vue-template-compiler": "^2.6.11",
"vuetify-loader": "^1.9.2"
}
}
So as can you see, I use Vue 2, Node 16 and compatible versions of Cypress. But I created 2 PRs to staging branch and nothing happened, as you can see in the image No Cypress Runs
How can I fix it? It is my first time creating an action and didn't found answers that solve my problem ?
I would like the test to run when creating the PR
Share asked Nov 22, 2024 at 5:04 Matheus PassosMatheus Passos 11 Answer
Reset to default 0my approach would be that you delete the types: [opened, synchronize, reopened]
line
"... if no activity types are specified, the workflow runs when a pull request is opened or reopened or when the head branch of the pull request is updated." ~ from github actions website
Looking like:
on:
pull_request:
branches:
- staging
本文标签: yamlGitHub Actions for Automatic Cypress Testing Not WorkingStack Overflow
版权声明:本文标题:yaml - GitHub Actions for Automatic Cypress Testing Not Working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742296536a2448842.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论