From 94e72402d4137a9568aa03d4194c169342a7d0d8 Mon Sep 17 00:00:00 2001 From: Peter Makowski Date: Mon, 10 Jun 2024 11:59:35 +0200 Subject: [PATCH] test publish action Signed-off-by: Peter Makowski --- .github/workflows/accessibility.yml | 45 ------------------ .github/workflows/cypress.yml | 73 ----------------------------- .github/workflows/links-checker.yml | 34 -------------- .github/workflows/playwright.yml | 35 -------------- .github/workflows/pr-lint.yml | 17 ------- .github/workflows/sitespeed.yml | 66 -------------------------- .github/workflows/test.yml | 73 ----------------------------- .github/workflows/tics.yml | 66 +++----------------------- .github/workflows/upload.yml | 54 --------------------- 9 files changed, 6 insertions(+), 457 deletions(-) delete mode 100644 .github/workflows/accessibility.yml delete mode 100644 .github/workflows/cypress.yml delete mode 100644 .github/workflows/links-checker.yml delete mode 100644 .github/workflows/playwright.yml delete mode 100644 .github/workflows/pr-lint.yml delete mode 100644 .github/workflows/sitespeed.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/upload.yml diff --git a/.github/workflows/accessibility.yml b/.github/workflows/accessibility.yml deleted file mode 100644 index d37b0fbe498..00000000000 --- a/.github/workflows/accessibility.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Accessibility -on: - push: - branches: - - main - - "3.*" -jobs: - cypress-axe: - name: cypress-axe - runs-on: ubuntu-22.04 - env: - MAAS_URL: http://localhost:5240 - 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: Install Cypress - uses: cypress-io/github-action@v4 - with: - runTests: false - install-command: yarn install - - name: Create MAAS admin - run: sudo maas createadmin --username=admin --password=test --email=fake@example.org - - name: Run cypress-axe accessibility tests - uses: cypress-io/github-action@v4 - with: - config: baseUrl=${{env.MAAS_URL}},pageLoadTimeout=100000 - install: false - spec: "cypress/e2e/accessibility/**/*.spec.ts" - wait-on: "${{env.MAAS_URL}}/MAAS/r/machines" - - name: Create issue on failure - if: failure() - 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 diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml deleted file mode 100644 index 384ca84c4b0..00000000000 --- a/.github/workflows/cypress.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: Cypress -on: - push: - branches: - - main - - "3.*" - - "*cypress*" - pull_request: - types: [opened, synchronize, reopened] - -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 - uses: nelonoel/branch-name@v1.0.1 - - name: Setup MAAS - uses: canonical/setup-maas@main - with: - maas-url: ${{ env.MAAS_URL }}/MAAS - - name: Install Cypress - uses: cypress-io/github-action@v4 - with: - runTests: false - install-command: yarn install - 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 - if: 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: cypress-screenshots - path: cypress/screenshots - - name: Create issue on failure - # Create an issue if the job fails on push to main or 3.* branches - if: failure() && github.event_name == 'push' && contains(fromJson('["main", "3.*"]'), env.BRANCH_NAME) - 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 \ No newline at end of file diff --git a/.github/workflows/links-checker.yml b/.github/workflows/links-checker.yml deleted file mode 100644 index b2705e4f220..00000000000 --- a/.github/workflows/links-checker.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: MAAS Docs link checker -on: - schedule: - - cron: "0 14 * * 1-5" # At 14:00 every day-of-week from Monday through Friday. - branches: - - main - - "3.5" - -jobs: - docs: - name: maas.io/docs links - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@main - - name: Get branch name - uses: nelonoel/branch-name@v1.0.1 - - name: Run Cypress docs tests - uses: cypress-io/github-action@v4 - with: - browser: chrome - config: baseUrl=http://maas.io/docs - spec: "cypress/e2e/docs-links/**/*.spec.ts" - install-command: yarn install - - name: Create issue on failure - if: failure() - 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 diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml deleted file mode 100644 index db34c24a74f..00000000000 --- a/.github/workflows/playwright.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Playwright Tests -on: - push: - branches: [main] -jobs: - test: - timeout-minutes: 15 - runs-on: ubuntu-latest - env: - MAAS_URL: localhost:5240 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - - name: Install dependencies - run: yarn - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - name: Setup MAAS - uses: canonical/setup-maas@main - with: - maas-url: ${{env.MAAS_URL}}/MAAS - - name: Create MAAS admin - run: sudo maas createadmin --username=admin --password=test --email=fake@example.org - - name: Wait for MAAS UI to be ready - run: yarn run wait-on http-get://${{env.MAAS_URL}}/MAAS/r - - name: Run Playwright tests - run: yarn playwright test - - uses: actions/upload-artifact@v4 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 diff --git a/.github/workflows/pr-lint.yml b/.github/workflows/pr-lint.yml deleted file mode 100644 index d33ccb0cb3c..00000000000 --- a/.github/workflows/pr-lint.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: "Lint PR" - -on: - pull_request: - types: [opened, edited, synchronize, reopened] - -permissions: - pull-requests: read - -jobs: - main: - name: Validate PR title - runs-on: ubuntu-22.04 - steps: - - uses: amannn/action-semantic-pull-request@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/sitespeed.yml b/.github/workflows/sitespeed.yml deleted file mode 100644 index c7c9d159c4e..00000000000 --- a/.github/workflows/sitespeed.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: sitespeed.io -on: - push: - branches: - - main - - "3.*" -jobs: - run-sitespeed: - name: Run sitespeed.io - runs-on: ubuntu-22.04 - strategy: - fail-fast: false - env: - MAAS_DOMAIN: localhost - MAAS_URL: http://localhost:5240 - steps: - - uses: actions/checkout@main - - name: Setup MAAS - uses: canonical/setup-maas@main - with: - maas-url: ${{ env.MAAS_URL }}/MAAS - use-maasdb-dump: true - maasdb-dump-url: https://github.com/canonical/maas-ui-testing/raw/main/db/maasdb-22.04-master-1000.dump - - name: Create MAAS admin - run: sudo maas createadmin --username=admin --password=test --email=fake@example.org - - name: Wait for MAAS - uses: nev7n/wait_for_response@v1 - with: - url: "http://${{env.MAAS_DOMAIN}}:5240/MAAS/r" - responseCode: 200 - timeout: 200000 - interval: 500 - - name: Login MAAS admin - run: | - # Retry admin login up to 5 times with 10s intervals to account for delays in MAAS becoming fully operational - for attempt in {1..5}; do - export API_KEY=$(sudo maas apikey --username=admin) - if maas login admin http://localhost:5240/MAAS $API_KEY; then - echo "Login successful." - break - else - echo "Login attempt $attempt failed. Retrying in 10 seconds..." - sleep 10 - fi - done - - name: Wait for MAAS boot resources - shell: bash - run: while [ $(maas admin boot-resources is-importing | cat) == "true" ]; do sleep 10; done; echo "syncing finished" - - name: Run sitespeed.io tests - run: yarn sitespeed:ci --browsertime.domain=${{env.MAAS_DOMAIN}} - - name: Upload results - uses: actions/upload-artifact@v4 - with: - name: sitespeed.io-results - path: sitespeed.io/results - - name: Create issue on failure - if: failure() - 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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 3352456ca1e..00000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: CI -on: - push: - branches: - - main - pull_request: - types: [opened, synchronize, reopened] -jobs: - lint: - name: Lint - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - name: Restore node_modules - id: yarn-cache - uses: actions/cache@v4 - with: - path: "**/node_modules" - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - name: Use Node.js from .nvmrc - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - - name: Install - if: steps.yarn-cache.outputs.cache-hit != 'true' - run: CYPRESS_INSTALL_BINARY=0 yarn install - - run: yarn lint - - test: - name: Test - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - name: Restore node_modules - id: yarn-cache - uses: actions/cache@v4 - with: - path: "**/node_modules" - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - name: Use Node.js from .nvmrc - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - - name: Install - if: steps.yarn-cache.outputs.cache-hit != 'true' - run: CYPRESS_INSTALL_BINARY=0 yarn install - - run: yarn test:ci - - build: - name: Build - timeout-minutes: 15 - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - name: Restore node_modules - id: yarn-cache - uses: actions/cache@v4 - with: - path: "**/node_modules" - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - name: Use Node.js from .nvmrc - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - - name: Install - if: steps.yarn-cache.outputs.cache-hit != 'true' - run: CYPRESS_INSTALL_BINARY=0 yarn install - - name: Build assets - run: yarn build - - name: Serve build - run: yarn serve --host --port=8400 --base=/ & - - name: Wait for UI to be ready - run: yarn wait-on-ui diff --git a/.github/workflows/tics.yml b/.github/workflows/tics.yml index d664a72f830..9700b5b9f9f 100644 --- a/.github/workflows/tics.yml +++ b/.github/workflows/tics.yml @@ -4,51 +4,21 @@ on: push: branches: - main - - ci-add-tics-workflow + - ci-test-coverage-publish jobs: - test-coverage: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version-file: ".nvmrc" - - - name: Install dependencies - run: yarn install - - - name: Run tests with coverage - run: | - set -x - yarn test:coverage - zip -r coverage/coverage-report.zip coverage/ - # Clean up any unwanted directories if necessary - find . -type d -name "unwanted-dir" -exec rm -r {} + - - - name: Upload coverage report - if: always() - uses: actions/upload-artifact@v4 - with: - name: coverage-report - path: coverage/coverage-report.zip - retention-days: 1 - publish-coverage-report: runs-on: ubuntu-latest - needs: test-coverage permissions: id-token: write + pages: write steps: - uses: actions/checkout@v4 - - name: Download coverage report - uses: actions/download-artifact@v4 - with: - name: coverage-report - path: coverage + - name: Download coverage report from external URL + run: | + curl -L -o coverage-report.zip "https://assets.ubuntu.com/v1/565c62a9-coverage.zip" + unzip -o coverage-report.zip -d coverage - name: Setup Pages uses: actions/configure-pages@v5 @@ -61,27 +31,3 @@ jobs: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 - - tics-report: - runs-on: ubuntu-latest - needs: publish-coverage-report - steps: - - uses: actions/checkout@v4 - - name: Run TICS Analyzer - uses: tiobe/tics-github-action@v3 - with: - mode: qserver - project: maas-ui - viewerUrl: https://canonical.tiobe.com/tiobeweb/TICS/api/cfg?name=config - ticsAuthToken: ${{ secrets.TICSAUTHTOKEN }} - installTics: true - tmpdir: /tmp/tics - branchdir: . - - - name: Upload TICS Report - if: always() - uses: actions/upload-artifact@v4 - with: - name: tics-report - path: /tmp/tics/ticstmpdir - retention-days: 7 diff --git a/.github/workflows/upload.yml b/.github/workflows/upload.yml deleted file mode 100644 index 714ceb8040a..00000000000 --- a/.github/workflows/upload.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Build upload -on: - push: - branches: - - main - - "3.*" -jobs: - upload-build: - if: github.repository_owner == 'canonical' - name: Upload build artifacts - runs-on: ubuntu-22.04 - env: - PACKAGE_NAME: maas-ui-${{ github.sha }}.tar.gz - VITE_APP_GIT_SHA: ${{ github.sha }} - steps: - - uses: actions/checkout@v4 - - name: Get branch name - uses: nelonoel/branch-name@v1.0.1 - - name: Restore node_modules - id: yarn-cache - uses: actions/cache@v4 - with: - path: "**/node_modules" - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - name: Use Node.js from .nvmrc - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - - name: Install - if: steps.yarn-cache.outputs.cache-hit != 'true' - run: CYPRESS_INSTALL_BINARY=0 yarn install - - name: Build - run: VITE_APP_GIT_SHA=${{env.VITE_APP_GIT_SHA}} yarn build - env: - CI: false - - name: Compress - run: cd build && tar -czf ../${{env.PACKAGE_NAME}} ./ && ls -hs ../${{env.PACKAGE_NAME}} - - name: Install upload-assets snap - run: sudo snap install upload-assets - - name: Upload to assets server - run: upload-assets --url-path ${{env.PACKAGE_NAME}} ${{env.PACKAGE_NAME}} - env: - UPLOAD_ASSETS_API_TOKEN: ${{secrets.UPLOAD_ASSETS_API_TOKEN}} - - name: Create issue on failure - if: failure() - 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