ci: run cypress on pr #5438
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cypress | |
on: | |
push: | |
branches: | |
- main | |
- "3.*" | |
- "*cypress*" | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
install: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Cypress install | |
uses: cypress-io/github-action@v2 | |
with: | |
runTests: false | |
install-command: yarn install --frozen-lockfile | |
build: yarn build | |
- name: Save build folder | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
if-no-files-found: error | |
path: build | |
cypress: | |
name: Cypress | |
runs-on: ubuntu-22.04 | |
needs: install | |
strategy: | |
fail-fast: false | |
matrix: | |
groups: ['no-users', 'with-users/priorityHigh', 'with-users/priorityLow'] | |
env: | |
MAAS_URL: http://localhost:5240 | |
MAAS_UI_URL: http://localhost:8400 | |
steps: | |
- uses: actions/checkout@main | |
- name: Get branch name | |
uses: nelonoel/branch-name@v1.0.1 | |
- name: Setup MAAS | |
uses: canonical/setup-maas@main | |
with: | |
maas-url: ${{ env.MAAS_URL }}/MAAS | |
- name: Download the build folder | |
uses: actions/download-artifact@v2 | |
with: | |
name: build | |
- name: Create MAAS admin | |
if: startsWith(matrix.groups, 'with-users') | |
run: sudo maas createadmin --username=admin --password=test --email=fake@example.org | |
- name: Create MAAS non-admin user | |
if: startsWith(matrix.groups, 'with-users') | |
run: | | |
export API_KEY=`sudo maas apikey --username=admin` | |
maas login admin http://localhost:5240/MAAS $API_KEY | |
maas admin users create username=user password=test email=fake-user@example.org is_superuser=0 | |
- name: Wait for MAAS boot resources | |
if: startsWith(matrix.groups, 'with-users') | |
shell: bash | |
run: while [ $(maas admin boot-resources is-importing | cat) == "true" ]; do sleep 10; done; echo "syncing finished" | |
- name: Run Cypress tests | |
uses: cypress-io/github-action@v4 | |
with: | |
config: baseUrl=${{env.MAAS_UI_URL}},pageLoadTimeout=100000 | |
install: false | |
start: yarn start | |
spec: cypress/e2e/${{ matrix.groups }}/**/*.spec.ts | |
wait-on: ${{env.MAAS_UI_URL}}/MAAS/r/machines | |
- uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: ${{ matrix.groups }}-cypress-screenshots | |
path: cypress/screenshots | |
- name: Create issue on failure | |
if: failure() && (github.ref_name == 'main' || github.ref_name == 'ci-run-cypress-on-pr' || startsWith(github.ref_name, '3.')) | |
uses: JasonEtco/create-an-issue@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
REPO: ${{ github.repository }} | |
RUN_ID: ${{ github.run_id }} | |
WORKFLOW: ${{ github.workflow }} | |
with: | |
filename: .github/ISSUE_TEMPLATE/ci-failure.md | |
update_existing: true |