From 7e83f093bc6e42f14ab71eca082c96a7f00ec5f4 Mon Sep 17 00:00:00 2001 From: Richard Cox <18697775+richard-cox@users.noreply.github.com> Date: Wed, 27 Sep 2023 17:38:04 +0100 Subject: [PATCH 1/3] Merge pull request #9763 from richard-cox/de-docker-file Remove two unused / maintained docker files and associated references --- .drone.yml | 64 ------------------- Dockerfile | 15 ----- Dockerfile.dev | 7 -- package.json | 1 - scripts/dev | 4 -- .../creators/app/files/.vscode/settings.json | 1 - shell/package.json | 1 - 7 files changed, 93 deletions(-) delete mode 100644 Dockerfile delete mode 100644 Dockerfile.dev delete mode 100755 scripts/dev diff --git a/.drone.yml b/.drone.yml index 71b699afed5..bca01e6dc38 100644 --- a/.drone.yml +++ b/.drone.yml @@ -18,70 +18,6 @@ steps: commands: - scripts/ci ---- -kind: pipeline -name: docker-branch - -depends_on: -- test - -trigger: - ref: - - "refs/heads/master" - - "refs/heads/*-dev" - - "refs/heads/release-*" - event: - - push - -platform: - os: linux - arch: amd64 - -steps: -- name: gate - pull: default - image: node:14 - commands: - - ./scripts/build-upload-gate - -- name: docker-image - image: plugins/docker - settings: - dockerfile: Dockerfile - tag: ${DRONE_BRANCH} - repo: rancherlabs/dashboard - username: - from_secret: docker_username - password: - from_secret: docker_password - ---- -kind: pipeline -name: docker-tag - -depends_on: -- test - -trigger: - event: - - tag - -platform: - os: linux - arch: amd64 - -steps: -- name: docker-image - image: plugins/docker - settings: - dockerfile: Dockerfile - tag: ${DRONE_TAG} - repo: rancherlabs/dashboard - username: - from_secret: docker_username - password: - from_secret: docker_password - --- kind: pipeline name: hosted-master diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index dae54dc710b..00000000000 --- a/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM node:14-alpine - -RUN mkdir /src -WORKDIR /src - -RUN apk update && apk upgrade - -COPY . /src - -RUN yarn --pure-lockfile install -RUN yarn build - -EXPOSE 80 -ENTRYPOINT ["yarn"] -CMD ["start"] diff --git a/Dockerfile.dev b/Dockerfile.dev deleted file mode 100644 index 114a0b0b9a0..00000000000 --- a/Dockerfile.dev +++ /dev/null @@ -1,7 +0,0 @@ -FROM node:12 - -RUN mkdir /src -WORKDIR /src - -EXPOSE 8005 -CMD ["scripts/dev"] diff --git a/package.json b/package.json index 774d5a1b953..e42f4a1f2f6 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "install:ci": "yarn install --frozen-lockfile", "dev": "bash -c 'source ./scripts/version && NODE_ENV=dev ./node_modules/.bin/vue-cli-service serve'", "mem-dev": "bash -c 'source ./scripts/version && NODE_ENV=dev node --max-old-space-size=8192 ./node_modules/.bin/vue-cli-service serve'", - "docker-dev": "docker run --rm --name dashboard-dev -p 8005:8005 -e API=$API -v $(pwd):/src -v dashboard_node:/src/node_modules rancher/dashboard:dev", "docker:local:start": "docker run -d --restart=unless-stopped -p 80:80 -p 443:443 -e CATTLE_BOOTSTRAP_PASSWORD=password -e CATTLE_PASSWORD_MIN_LENGTH=3 --name cypress --privileged rancher/rancher:v2.7-head", "docker:local:stop": "docker kill cypress || true && docker rm cypress || true", "build": "NODE_OPTIONS=--max_old_space_size=4096 ./node_modules/.bin/vue-cli-service build", diff --git a/scripts/dev b/scripts/dev deleted file mode 100755 index d70983bf054..00000000000 --- a/scripts/dev +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -yarn --pure-lockfile install -exec yarn dev diff --git a/shell/creators/app/files/.vscode/settings.json b/shell/creators/app/files/.vscode/settings.json index a023daf1395..e8ba4cbac5c 100644 --- a/shell/creators/app/files/.vscode/settings.json +++ b/shell/creators/app/files/.vscode/settings.json @@ -10,7 +10,6 @@ ".gitignore": true, ".nuxt*": true, ".nyc_output": true, - "Dockerfile": true, ".vscode": true, "LICENSE": true, "node_modules": true, diff --git a/shell/package.json b/shell/package.json index 4c74bf694e6..d8b9067c315 100644 --- a/shell/package.json +++ b/shell/package.json @@ -17,7 +17,6 @@ "lint": "./node_modules/.bin/eslint --max-warnings 0 --ext .ts,.js,.vue .", "test": "./node_modules/.bin/nyc ava --serial --verbose", "dev": "./node_modules/.bin/vue-cli-service dev", - "docker-dev": "docker run --rm --name dashboard-dev -p 8005:8005 -e API=$API -v $(pwd):/src -v dashboard_node:/src/node_modules rancher/dashboard:dev", "build": "./node_modules/.bin/vue-cli-service build", "analyze": "./node_modules/.bin/vue-cli-service build --report", "start": "./node_modules/.bin/vue-cli-service start", From b5a6718a743c556b4cae79c486b5479940787617 Mon Sep 17 00:00:00 2001 From: Richard Cox <18697775+richard-cox@users.noreply.github.com> Date: Mon, 20 May 2024 11:12:50 +0100 Subject: [PATCH 2/3] Merge pull request #11018 from rancher/richard-cox-2.8-drone [2.8] Port drone build tasks to gh workflows + actions --- .drone.yml | 278 ------------------ .github/actions/i18n-lint/action.yaml | 12 + .github/actions/lint/action.yaml | 12 + .github/actions/setup/action.yaml | 14 + .github/actions/unit-tests/action.yaml | 14 + .../workflows/build-and-upload-branch.yaml | 21 ++ .../build-and-upload-release-2-8.yaml | 20 ++ .github/workflows/build-and-upload.yaml | 111 +++++++ .github/workflows/build-test.yaml | 37 +++ .github/workflows/test.yaml | 117 +++++--- README.md | 1 - package.json | 5 +- scripts/build-e2e | 4 +- scripts/build-embedded | 7 +- scripts/build-hosted | 8 +- scripts/build-upload-gate | 18 +- scripts/ci | 25 -- scripts/version | 2 +- 18 files changed, 344 insertions(+), 362 deletions(-) delete mode 100644 .drone.yml create mode 100644 .github/actions/i18n-lint/action.yaml create mode 100644 .github/actions/lint/action.yaml create mode 100644 .github/actions/setup/action.yaml create mode 100644 .github/actions/unit-tests/action.yaml create mode 100644 .github/workflows/build-and-upload-branch.yaml create mode 100644 .github/workflows/build-and-upload-release-2-8.yaml create mode 100644 .github/workflows/build-and-upload.yaml create mode 100644 .github/workflows/build-test.yaml delete mode 100755 scripts/ci diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index bca01e6dc38..00000000000 --- a/.drone.yml +++ /dev/null @@ -1,278 +0,0 @@ ---- -kind: pipeline -name: test - -trigger: - event: - - push - - tag - -platform: - os: linux - arch: amd64 - -steps: -- name: test - pull: default - image: node:14 - commands: - - scripts/ci - ---- -kind: pipeline -name: hosted-master - -depends_on: -- test - -trigger: - ref: - - "refs/heads/master" - event: - - push - -platform: - os: linux - arch: amd64 - -steps: -- name: build - pull: default - image: node:14 - commands: - - ./scripts/build-hosted - -- name: upload-gate - pull: default - image: node:14 - commands: - - ./scripts/build-upload-gate - -- name: upload - pull: default - image: plugins/gcs - settings: - acl: - - allUsers:READER - cache_control: "no-cache,must-revalidate" - source: dist/latest - target: releases.rancher.com/dashboard/latest - token: - from_secret: google_auth_key - ---- -kind: pipeline -name: hosted-branch - -depends_on: -- test - -trigger: - ref: - - "refs/heads/*-dev" - - "refs/heads/release-*" - event: - - push - -platform: - os: linux - arch: amd64 - -steps: -- name: build - pull: default - image: node:14 - commands: - - ./scripts/build-hosted - -- name: upload - pull: default - image: plugins/gcs - settings: - acl: - - allUsers:READER - cache_control: "no-cache,must-revalidate" - source: dist/${DRONE_BRANCH} - target: releases.rancher.com/dashboard/${DRONE_BRANCH} - token: - from_secret: google_auth_key - ---- -kind: pipeline -name: hosted-tag - -depends_on: -- test - -trigger: - event: - - tag - -platform: - os: linux - arch: amd64 - -steps: -- name: build - pull: default - image: node:14 - commands: - - ./scripts/build-hosted - -- name: upload - pull: default - image: plugins/gcs - settings: - acl: - - allUsers:READER - cache_control: "no-cache,must-revalidate" - source: dist/${DRONE_TAG} - target: releases.rancher.com/dashboard/${DRONE_TAG} - token: - from_secret: google_auth_key - -- name: create-pr-in-rancher - image: curlimages/curl:7.81.0 - user: root - environment: - PAT_USERNAME: - from_secret: pat_username - PAT_TOKEN: - from_secret: github_token - commands: - - apk -U --no-cache add bash - - scripts/create-pr-in-rancher ---- -kind: pipeline -name: embedded-master - -depends_on: -- test - -trigger: - ref: - - "refs/heads/master" - event: - - push - -platform: - os: linux - arch: amd64 - -steps: -- name: build - pull: default - image: node:14 - environment: - EMBED_PKG: https://releases.rancher.com/harvester-ui/plugin/harvester-1.0.3.tar.gz - commands: - - ./scripts/build-embedded - -- name: upload-gate - pull: default - image: node:14 - commands: - - ./scripts/build-upload-gate - -- name: upload - pull: default - image: plugins/gcs - settings: - acl: - - allUsers:READER - cache_control: "no-cache,must-revalidate" - source: dist/${DRONE_BRANCH}.tar.gz - target: releases.rancher.com/dashboard/latest.tar.gz - token: - from_secret: google_auth_key - ---- -kind: pipeline -name: embedded-branch - -depends_on: -- test - -trigger: - ref: - - "refs/heads/*-dev" - - "refs/heads/release-*" - event: - - push - -platform: - os: linux - arch: amd64 - -steps: -- name: build - pull: default - image: node:14 - environment: - EMBED_PKG: https://releases.rancher.com/harvester-ui/plugin/harvester-1.0.3.tar.gz - commands: - - ./scripts/build-embedded - -- name: upload - pull: default - image: plugins/gcs - settings: - acl: - - allUsers:READER - cache_control: "no-cache,must-revalidate" - source: dist/${DRONE_BRANCH}.tar.gz - target: releases.rancher.com/dashboard/${DRONE_BRANCH}.tar.gz - token: - from_secret: google_auth_key - ---- -kind: pipeline -name: embedded-tag - -depends_on: -- test - -trigger: - event: - - tag - -platform: - os: linux - arch: amd64 - -steps: -- name: build - pull: default - image: node:14 - environment: - EMBED_PKG: https://releases.rancher.com/harvester-ui/plugin/harvester-1.0.3.tar.gz - commands: - - ./scripts/build-embedded - -- name: upload - pull: default - image: plugins/gcs - settings: - acl: - - allUsers:READER - cache_control: "no-cache,must-revalidate" - source: dist/${DRONE_TAG}.tar.gz - target: releases.rancher.com/dashboard/${DRONE_TAG}.tar.gz - token: - from_secret: google_auth_key - -# --- - -# kind: pipeline -# name: fossa - -# steps: -# - name: fossa -# image: rancher/drone-fossa:latest -# failure: ignore -# settings: -# api_key: -# from_secret: FOSSA_API_KEY -# when: -# instance: -# - drone-publish.rancher.io \ No newline at end of file diff --git a/.github/actions/i18n-lint/action.yaml b/.github/actions/i18n-lint/action.yaml new file mode 100644 index 00000000000..2464bc926d5 --- /dev/null +++ b/.github/actions/i18n-lint/action.yaml @@ -0,0 +1,12 @@ +name: Run i18n Lint +description: Run i18n Lint + +runs: + using: 'composite' + steps: + - name: Setup env + uses: ./.github/actions/setup + + - name: Run i18n linters + shell: bash + run: yarn lint-l10n diff --git a/.github/actions/lint/action.yaml b/.github/actions/lint/action.yaml new file mode 100644 index 00000000000..77895a3cf3c --- /dev/null +++ b/.github/actions/lint/action.yaml @@ -0,0 +1,12 @@ +name: Run Lint +description: Run Lint + +runs: + using: 'composite' + steps: + - name: Setup env + uses: ./.github/actions/setup + + - name: Run linters + shell: bash + run: yarn lint diff --git a/.github/actions/setup/action.yaml b/.github/actions/setup/action.yaml new file mode 100644 index 00000000000..53b8ef4abc1 --- /dev/null +++ b/.github/actions/setup/action.yaml @@ -0,0 +1,14 @@ +name: Setup UI Env +description: Setup node, python and call bootstrap script + +runs: + using: 'composite' + steps: + - uses: actions/setup-node@v3 + with: + node-version: '14.x' + cache: 'yarn' + + - name: Install packages + shell: bash + run: yarn install:ci diff --git a/.github/actions/unit-tests/action.yaml b/.github/actions/unit-tests/action.yaml new file mode 100644 index 00000000000..a7ad8b8346f --- /dev/null +++ b/.github/actions/unit-tests/action.yaml @@ -0,0 +1,14 @@ +name: Run Unit Tests +description: Run Unit Tests + +runs: + using: 'composite' + steps: + - name: Setup env + uses: ./.github/actions/setup + + - name: Run tests + shell: bash + run: | + yarn test:ci + \ No newline at end of file diff --git a/.github/workflows/build-and-upload-branch.yaml b/.github/workflows/build-and-upload-branch.yaml new file mode 100644 index 00000000000..c937ae15efe --- /dev/null +++ b/.github/workflows/build-and-upload-branch.yaml @@ -0,0 +1,21 @@ +name: Build Dashboard (Branch) +on: + push: + branches: + - 'release-2.8*' + - '*-dev' + +jobs: + build-validation: + name: Build Test + uses: ./.github/workflows/build-test.yaml + build: + name: Build and Upload + uses: ./.github/workflows/build-and-upload.yaml + needs: + - build-validation + permissions: + contents: 'read' + id-token: 'write' + with: + CI_BRANCH: ${{github.ref_name}} diff --git a/.github/workflows/build-and-upload-release-2-8.yaml b/.github/workflows/build-and-upload-release-2-8.yaml new file mode 100644 index 00000000000..79bdb02031e --- /dev/null +++ b/.github/workflows/build-and-upload-release-2-8.yaml @@ -0,0 +1,20 @@ +name: Build Dashboard 2.8 (Release) +on: + push: + tags: + - v2.8.* + +jobs: + build-validation: + name: Validate Code + uses: ./.github/workflows/build-test.yaml + build: + name: Build and Upload + uses: ./.github/workflows/build-and-upload.yaml + needs: + - build-validation + permissions: + contents: 'read' + id-token: 'write' + with: + CI_BUILD_TAG: ${{github.ref_name}} diff --git a/.github/workflows/build-and-upload.yaml b/.github/workflows/build-and-upload.yaml new file mode 100644 index 00000000000..1d09571449c --- /dev/null +++ b/.github/workflows/build-and-upload.yaml @@ -0,0 +1,111 @@ +name: Build Dashboard and Upload + +on: + workflow_call: + inputs: + CI_BRANCH: + required: false + type: string + CI_BUILD_TAG: + required: false + type: string + +env: + CI_BUILD_TAG: ${{inputs.CI_BUILD_TAG}} + CI_BRANCH: ${{inputs.CI_BRANCH}} + GIT_REPO: ${{github.repository}} + GIT_COMMIT: ${{github.sha}} + REPO: ${{github.event.repository.name || ''}} + +jobs: + build-and-upload-hosted: + name: Build & Upload Hosted + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + # Note - Cannot use the setup action here as it uses a different yarn install arg + - uses: actions/setup-node@v3 + with: + node-version: '14.x' + cache: 'yarn' + + # Build a directory containing the dashboard that can be used with ui-dashboard-index + - id: build-hosted + name: Build Hosted + run: ./scripts/build-hosted + + - id: upload-gate + name: Upload Gate (superceded by a newer build?) + run: ./scripts/build-upload-gate + + - name: Get gcs auth + uses: rancher-eio/read-vault-secrets@main + with: + secrets: | + secret/data/github/repo/${{ github.repository }}/google-auth/rancher/credentials token | GOOGLE_AUTH + + - name: Apply gcs auth + # https://github.com/google-github-actions/auth + uses: 'google-github-actions/auth@v2' + with: + credentials_json: "${{ env.GOOGLE_AUTH }}" + + - name: Upload build + uses: 'google-github-actions/upload-cloud-storage@v2' + # https://github.com/google-github-actions/upload-cloud-storage + with: + path: ${{steps.build-hosted.outputs.BUILD_HOSTED_DIR}} + # Example - https://releases.rancher.com/ui/2.8.0/... + destination: releases.rancher.com/${{ env.REPO }}/${{ steps.build-hosted.outputs.BUILD_HOSTED_LOCATION }} + parent: false + headers: |- + cache-control: no-cache,must-revalidate + process_gcloudignore: false + + build-and-upload-embedded: + name: Build & Upload Embedded + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + # Note - Cannot use the setup action here as it uses a different yarn install arg + - uses: actions/setup-node@v3 + with: + node-version: '14.x' + cache: 'yarn' + + # Build a tar that will be picked up by rancher builds and embedded into it + - id: build-embedded + name: Build Embedded + run: ./scripts/build-embedded + env: + EMBED_PKG: https://releases.rancher.com/harvester-ui/plugin/harvester-1.0.3.tar.gz + + - name: Get gcs auth + uses: rancher-eio/read-vault-secrets@main + with: + secrets: | + secret/data/github/repo/${{ github.repository }}/google-auth/rancher/credentials token | GOOGLE_AUTH + + - name: Apply gcs auth + # https://github.com/google-github-actions/auth + uses: 'google-github-actions/auth@v2' + with: + credentials_json: "${{ env.GOOGLE_AUTH }}" + + - name: Upload tar + uses: 'google-github-actions/upload-cloud-storage@v2' + with: + path: ${{steps.build-embedded.outputs.BUILD_EMBEDED_TGZ}} + # Example - https://releases.rancher.com/ui/2.8.0.tar.gz + destination: releases.rancher.com/${{ env.REPO }} + parent: false + headers: |- + cache-control: no-cache,must-revalidate + process_gcloudignore: false + \ No newline at end of file diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml new file mode 100644 index 00000000000..b8ba454680f --- /dev/null +++ b/.github/workflows/build-test.yaml @@ -0,0 +1,37 @@ +# Validation steps required before a build occurs. Not designed to replace the CI test workflow +name: Build Test + +on: + # This tells GH that the workflow is reusable + workflow_call: + +jobs: + unit-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Run tests + uses: ./.github/actions/unit-tests + + i18n: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Run i18n lint + uses: ./.github/actions/i18n-lint + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Run lint + uses: ./.github/actions/lint diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index edd9f416270..7668ec0893e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,18 +2,17 @@ name: Tests on: push: branches: - - master - - 'release-*' + - 'release-2.8*' pull_request: - branches: - - master - - 'release-*' + branches: + - 'release-2.8*' workflow_dispatch: - environment: - description: 'Environment to run tests against' - type: environment - required: true - + inputs: + environment: + description: 'Environment to run tests against' + type: environment + required: true + env: TEST_USERNAME: admin TEST_PASSWORD: password @@ -25,23 +24,73 @@ env: TEST_RUN_ID: ${{github.run_number}}-${{github.run_attempt}}-${{github.event.pull_request.title || github.event.head_commit.message}} CYPRESS_coverage: true + E2E_BUILD_DIST_NAME: dist + E2E_BUILD_DIST_DIR: dist + E2E_BUILD_DIST_EMBER_NAME: dist_ember + E2E_BUILD_DIST_EMBER_DIR: dist_ember + jobs: + e2e-ui-build: + if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + - name: Setup env + uses: ./.github/actions/setup + - name: Build e2e + run: yarn e2e:build + - name: Upload e2e build + uses: actions/upload-artifact@v4 + with: + name: ${{ env.E2E_BUILD_DIST_NAME }} + path: ${{ env.E2E_BUILD_DIST_DIR }}/ + if-no-files-found: error + retention-days: 10 + compression-level: 9 + - name: Upload e2e build ember + uses: actions/upload-artifact@v4 + with: + name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} + path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }}/ + if-no-files-found: error + retention-days: 10 + compression-level: 9 e2e-test: if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" + needs: e2e-ui-build runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: fetch-depth: 1 - - uses: actions/setup-node@v3 + - name: Setup env + uses: ./.github/actions/setup + + # Installing fixed version of Chrome since latest version does not work (117-118 didn't work) + # Leaving this here again in case we need to pin to a specific Chrome version in the future + # - name: Install Chrome 116 + # run: | + # sudo apt-get install -y wget + # cd /tmp + # wget -q http://mirror.cs.uchicago.edu/google-chrome/pool/main/g/google-chrome-stable/google-chrome-stable_116.0.5845.187-1_amd64.deb + # sudo apt-get install -y --allow-downgrades ./google-chrome-stable_116.0.5845.187-1_amd64.deb + # google-chrome --version + + - name: Download e2e build + uses: actions/download-artifact@v4 with: - node-version: '14.x' - - - name: Install packages - run: yarn install:ci + name: ${{ env.E2E_BUILD_DIST_NAME }} + path: ${{ env.E2E_BUILD_DIST_DIR }} + - name: Download e2e build ember + uses: actions/download-artifact@v4 + with: + name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }} + path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }} - - name: Prepare build - run: yarn e2e:pre-prod + - name: Run Rancher + run: yarn e2e:docker - name: Run admin user tests run: | @@ -83,16 +132,12 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 1 - - uses: actions/setup-node@v3 - with: - node-version: '14.x' - - - name: Install packages - run: yarn install:ci - name: Run tests + uses: ./.github/actions/unit-tests + + - name: Collect Coverage run: | - yarn test:ci mkdir -p coverage-artifacts/coverage cp coverage/unit/coverage-final.json coverage-artifacts/coverage/coverage-unit.json @@ -108,15 +153,9 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 1 - - uses: actions/setup-node@v3 - with: - node-version: '14.x' - - - name: Install packages - run: yarn install:ci - - - name: Run i18n linters - run: yarn lint-l10n + + - name: Run i18n lint + uses: ./.github/actions/i18n-lint lint: runs-on: ubuntu-latest @@ -124,15 +163,9 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 1 - - uses: actions/setup-node@v3 - with: - node-version: '14.x' - - - name: Install packages - run: yarn install:ci - - - name: Run linters - run: yarn lint + + - name: Run tests + uses: ./.github/actions/lint coverage: if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')" diff --git a/README.md b/README.md index e75b41a774c..5a42fc41111 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ Developer documentation and documentation for our UI components is available her Rancher Dashboard supports an extension mechanism that allows developers to build there own extensions that can be developed independently of Rancher and loaded into a deployed Rancher installation to extend its functionality. You can learn more from our [Rancher Extensions Docs](https://rancher.github.io/dashboard/extensions/introduction). - # What is it? Rancher Dashboard provides a sophisticated UI for managing Kubernetes clusters and Workloads. diff --git a/package.json b/package.json index e42f4a1f2f6..afb4b9867ad 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "cy:open": "cypress open", "cy:run": "cypress run --browser chrome", "cy:run:sorry": "./scripts/e2e", - "e2e:pre-dev": "yarn docker:local:stop && yarn docker:local:start && NODE_ENV=dev TEST_INSTRUMENT=true yarn build", + "e2e:build": "mkdir dist && TEST_INSTRUMENT=true ./scripts/build-e2e", + "e2e:docker": "yarn docker:local:stop && ./scripts/e2e-docker-start ", "e2e:dev": "START_SERVER_AND_TEST_INSECURE=1 server-test start:dev https-get://localhost:8005 cy:run:sorry", "e2e:pre-prod": "yarn docker:local:stop && mkdir dist && TEST_INSTRUMENT=true ./scripts/build-e2e && ./scripts/e2e-docker-start ", "e2e:prod": "GREP_TAGS=$GREP_TAGS TEST_USERNAME=$TEST_USERNAME TEST_BASE_URL=https://127.0.0.1/dashboard yarn cy:run:sorry", @@ -216,4 +217,4 @@ ], "report-dir": "coverage/e2e" } -} +} \ No newline at end of file diff --git a/scripts/build-e2e b/scripts/build-e2e index 40cb8e30612..6c6162841d2 100755 --- a/scripts/build-e2e +++ b/scripts/build-e2e @@ -24,7 +24,7 @@ source scripts/version echo "BRANCH: ${COMMIT_BRANCH:-}" echo "TAG: ${GIT_TAG:-}" -OUTPUT_DIR=dist +OUTPUT_DIR="${E2E_BUILD_DIST_DIR:-dist}" echo "Building..." COMMIT=${COMMIT} VERSION=${VERSION} OUTPUT_DIR=$OUTPUT_DIR ROUTER_BASE='/dashboard/' RESOURCE_BASE='/dashboard/' yarn run build @@ -33,7 +33,7 @@ COMMIT=${COMMIT} VERSION=${VERSION} OUTPUT_DIR=$OUTPUT_DIR ROUTER_BASE='/dashboa # Note - We can't pull the `latest2` directory from CDN and we don't build a tar.gz for latest builds... # ..so just fetch the latest index.html which references latest CDN bits -OUTPUT_EMBER_DIR=dist_ember +OUTPUT_EMBER_DIR="${E2E_BUILD_DIST_EMBER_DIR:-dist_ember}" echo "Pulling latest rancher/ui" mkdir $OUTPUT_EMBER_DIR diff --git a/scripts/build-embedded b/scripts/build-embedded index 14ebb7b63cc..6e673b61853 100755 --- a/scripts/build-embedded +++ b/scripts/build-embedded @@ -45,8 +45,13 @@ find $OUTPUT_DIR -name "index.html" -mindepth 2 -exec rm {} \; find $OUTPUT_DIR -type d -empty -depth -exec rmdir {} \; TARBALL=${DIR}.tar.gz +TARBALL_FILE_PATH=dist/${TARBALL} + +ENV_OUTPUT="${GITHUB_OUTPUT:-"temp-env"}" +echo "BUILD_EMBEDED_TGZ=${TARBALL_FILE_PATH}" >> "$ENV_OUTPUT" + echo "Compressing to ${TARBALL}..." -tar -czf dist/${TARBALL} $OUTPUT_DIR/ +tar -czf ${TARBALL_FILE_PATH} $OUTPUT_DIR/ echo "Cleaning up..." rm -r $OUTPUT_DIR diff --git a/scripts/build-hosted b/scripts/build-hosted index 865347804ff..0d58d1775ab 100755 --- a/scripts/build-hosted +++ b/scripts/build-hosted @@ -25,4 +25,10 @@ BASE=${BASE:-https://releases.rancher.com/dashboard/${DIR}} echo "Building for ${BASE}..." -COMMIT=${COMMIT} VERSION=${VERSION} OUTPUT_DIR=dist/${DIR} ROUTER_BASE="/dashboard/" RESOURCE_BASE="${BASE}" yarn run build +OUTPUT_DIR=dist/${DIR} + +ENV_OUTPUT="${GITHUB_OUTPUT:-"temp-env"}" +echo "BUILD_HOSTED_DIR=${OUTPUT_DIR}" >> "$ENV_OUTPUT" +echo "BUILD_HOSTED_LOCATION=${DIR}" >> "$ENV_OUTPUT" + +COMMIT=${COMMIT} VERSION=${VERSION} OUTPUT_DIR=${OUTPUT_DIR} ROUTER_BASE="/dashboard/" RESOURCE_BASE="${BASE}" yarn run build diff --git a/scripts/build-upload-gate b/scripts/build-upload-gate index 4317abda405..13c494d1769 100755 --- a/scripts/build-upload-gate +++ b/scripts/build-upload-gate @@ -9,32 +9,32 @@ if [[ -n "${BUILD_DEBUG}" ]]; then env fi -if [[ -n "$DRONE_TAG" ]]; then +if [[ -n "$CI_BUILD_TAG" ]]; then echo "Build has been triggered by a tag. Skipping gate" exit 0 fi -if [[ -z "$DRONE_BRANCH" ]]; then +if [[ -z "$CI_BRANCH" ]]; then echo "No branch detected. Skipping gate" exit 0 fi -if [[ -z "$DRONE_REPO" ]]; then +if [[ -z "$GIT_REPO" ]]; then echo "No repository detected. Unable to gate" exit 1 fi -if [[ -z "$DRONE_COMMIT" ]]; then +if [[ -z "$GIT_COMMIT" ]]; then echo "No commit detected. Unable to gate" exit 1 fi -echo "Repo: $DRONE_REPO" -echo "Branch: $DRONE_BRANCH" -echo "Build Commit: $DRONE_COMMIT" +echo "Repo: $GIT_REPO" +echo "Branch: $CI_BRANCH" +echo "Build Commit: $GIT_COMMIT" tmp=$(mktemp -u) -STATUS_CODE=$(curl -w "%{http_code}" -s -o $tmp https://api.github.com/repos/$DRONE_REPO/branches/$DRONE_BRANCH) +STATUS_CODE=$(curl -w "%{http_code}" -s -o $tmp https://api.github.com/repos/$GIT_REPO/branches/$CI_BRANCH) if [ "$STATUS_CODE" == "403" ]; then RATE_LIMIT_REMAINING=$(curl -s https://api.github.com/rate_limit | ./scripts/jq-nano - rate remaining) @@ -55,7 +55,7 @@ if [ -z "$LATEST_BRANCH_COMMIT" ]; then exit 1 fi -if [ "$LATEST_BRANCH_COMMIT" == "$DRONE_COMMIT" ]; then +if [ "$LATEST_BRANCH_COMMIT" == "$GIT_COMMIT" ]; then echo "Build was created from latest commit, passed upload gate" else echo "Build was not created from latest commit, failing gate" diff --git a/scripts/ci b/scripts/ci deleted file mode 100755 index 6848c5258b1..00000000000 --- a/scripts/ci +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -set -e - -BUILD_DEBUG="${BUILD_DEBUG:-}" -if [[ -n "${BUILD_DEBUG}" ]]; then - set -x - env -fi - -cd $(dirname $0)/.. - -echo "Bootstrapping..." -yarn --pure-lockfile install - -echo "Linting..." -yarn run lint - -echo "Linting translations..." -yarn run lint-l10n - -echo "Testing..." -yarn run test:ci - -echo "Building..." -yarn run build diff --git a/scripts/version b/scripts/version index c1eee348da8..d4af4084bdf 100755 --- a/scripts/version +++ b/scripts/version @@ -8,7 +8,7 @@ fi COMMIT=$(git rev-parse --short HEAD) COMMIT_DATE=$(git --no-pager log -1 --format='%ct') COMMIT_BRANCH=$(git rev-parse --abbrev-ref HEAD | sed -E 's/[^a-zA-Z0-9.-]+/-/g') -GIT_TAG=${DRONE_TAG:-$(git tag -l --contains HEAD | head -n 1)} +GIT_TAG=${CI_BUILD_TAG:-$(git tag -l --contains HEAD | head -n 1)} LAST_TAG=${GIT_TAG:-'v0.0.0'} if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then From bfd67b3da3ee8b2f3abeead8864bf26e2dbc1a3a Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Mon, 20 May 2024 11:30:44 +0100 Subject: [PATCH 3/3] Changes post cherry-pick --- .github/workflows/build-and-upload-branch.yaml | 2 +- ...d-release-2-8.yaml => build-and-upload-release-2-7.yaml} | 4 ++-- .github/workflows/test.yaml | 4 ++-- .vscode/settings.json | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) rename .github/workflows/{build-and-upload-release-2-8.yaml => build-and-upload-release-2-7.yaml} (87%) diff --git a/.github/workflows/build-and-upload-branch.yaml b/.github/workflows/build-and-upload-branch.yaml index c937ae15efe..4f1661e5efc 100644 --- a/.github/workflows/build-and-upload-branch.yaml +++ b/.github/workflows/build-and-upload-branch.yaml @@ -2,7 +2,7 @@ name: Build Dashboard (Branch) on: push: branches: - - 'release-2.8*' + - 'release-2.7*' - '*-dev' jobs: diff --git a/.github/workflows/build-and-upload-release-2-8.yaml b/.github/workflows/build-and-upload-release-2-7.yaml similarity index 87% rename from .github/workflows/build-and-upload-release-2-8.yaml rename to .github/workflows/build-and-upload-release-2-7.yaml index 79bdb02031e..e530ead5f2d 100644 --- a/.github/workflows/build-and-upload-release-2-8.yaml +++ b/.github/workflows/build-and-upload-release-2-7.yaml @@ -1,8 +1,8 @@ -name: Build Dashboard 2.8 (Release) +name: Build Dashboard 2.7 (Release) on: push: tags: - - v2.8.* + - v2.7.* jobs: build-validation: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7668ec0893e..a1e34944bd9 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,10 +2,10 @@ name: Tests on: push: branches: - - 'release-2.8*' + - 'release-2.7*' pull_request: branches: - - 'release-2.8*' + - 'release-2.7*' workflow_dispatch: inputs: environment: diff --git a/.vscode/settings.json b/.vscode/settings.json index b79ef34b5cb..f6c83b73ea7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,9 +9,9 @@ "eslint.format.enable": true, "eslint.run": "onSave", "eslint.packageManager": "yarn", - "eslint.validate": ["vue","html","javascript","typescript"], + "eslint.validate": ["vue", "html", "javascript", "typescript"], "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "source.fixAll.eslint": "explicit" }, "eslint.workingDirectories": ["./", "./pkg/rancher-components/"], "javascript.preferences.importModuleSpecifier": "non-relative", @@ -51,4 +51,4 @@ "vuex", "whatsnew" ], -} +} \ No newline at end of file