diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 1fd949cc0b..40c29b23a2 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -5,12 +5,18 @@ on: - main - "3.*" - "*cypress*" + jobs: cypress: name: Cypress runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + groups: ['no-users', 'with-users'] env: MAAS_URL: http://localhost:5240 + MAAS_UI_URL: http://localhost:8400 steps: - uses: actions/checkout@main - name: Get branch name @@ -18,35 +24,30 @@ jobs: - name: Setup MAAS uses: canonical/setup-maas@main with: - maas-url: ${{env.MAAS_URL}}/MAAS + maas-url: ${{ env.MAAS_URL }}/MAAS - name: Install Cypress uses: cypress-io/github-action@v4 with: runTests: false install-command: yarn install - - name: Run Cypress tests without a user - uses: cypress-io/github-action@v4 - with: - config: baseUrl=${{env.MAAS_URL}},pageLoadTimeout=100000 - install: false - spec: "cypress/e2e/no-users/**/*.spec.ts" - wait-on: "${{env.MAAS_URL}}/MAAS/r/machines" + build: yarn build - name: Create MAAS admin + if: matrix.groups == 'with-users' run: sudo maas createadmin --username=admin --password=test --email=fake@example.org - name: Create MAAS non-admin user + if: 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 - run: while [ $(maas admin boot-resources is-importing | cat) == "true" ]; do sleep 10; done; echo "syncing finished" - - name: Run Cypress tests with a user + - name: Run Cypress tests uses: cypress-io/github-action@v4 with: - config: baseUrl=${{env.MAAS_URL}},pageLoadTimeout=100000 + config: baseUrl=${{env.MAAS_UI_URL}},pageLoadTimeout=100000 install: false - spec: "cypress/e2e/with-users/**/*.spec.ts" - wait-on: "${{env.MAAS_URL}}/MAAS/r/machines" + 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: @@ -62,4 +63,4 @@ jobs: WORKFLOW: ${{ github.workflow }} with: filename: .github/ISSUE_TEMPLATE/ci-failure.md - update_existing: true + update_existing: true \ No newline at end of file