diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..bf9ba4a21 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,24 @@ +name: dpc-sdp/ripple/build +on: + workflow_call: +env: + CONTENT_API_SERVER: ${{ vars.CONTENT_API_SERVER }} +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3.5.0 + - uses: actions/setup-node@v3.6.0 + with: + node-version: '14' + - name: Restore cache + uses: actions/cache@v3.3.1 + with: + key: v10-deps-${{ hashFiles('yarn.lock') }} + path: | + ./.cache + **/node_modules + - name: Install Dependencies + run: yarn install --frozen-lockfile --cache-folder .cache/yarn + - name: Build reference nuxt app + run: yarn reference:build \ No newline at end of file diff --git a/.github/workflows/canary-npm-release.yml b/.github/workflows/canary-npm-release.yml new file mode 100644 index 000000000..5867525a6 --- /dev/null +++ b/.github/workflows/canary-npm-release.yml @@ -0,0 +1,26 @@ +name: dpc-sdp/ripple/canary-npm-release +on: + push: + branches: + # Uncomment below once testing has been completed and we are ready to publish using this workflow + #- uat + - 'github-action/disable-workflow' +jobs: + build: + uses: ./.github/workflows/build.yml + test: + needs: + - build + uses: ./.github/workflows/test.yml + create-prerelease: + needs: + - test + uses: ./.github/workflows/create-release.yml + with: + canary-prerelease: true + tag-release: + needs: + - create-prerelease + permissions: + contents: write + uses: ./.github/workflows/tag-release.yml diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml new file mode 100644 index 000000000..5418e7d79 --- /dev/null +++ b/.github/workflows/commit.yml @@ -0,0 +1,35 @@ +name: dpc-sdp/ripple/commit +on: + workflow_call: + push: + branches-ignore: + - master +env: + CHROMATIC_APP_CODE: ${{ secrets.CHROMATIC_APP_CODE }} +jobs: + build: + uses: ./.github/workflows/build.yml + test: + needs: + - build + uses: ./.github/workflows/test.yml + storybook: + runs-on: ubuntu-latest + needs: + - build + steps: + - uses: actions/checkout@v3.5.0 + with: + fetch-depth: 0 # 👈 Required to retrieve git history + - uses: actions/setup-node@v3.6.0 + with: + node-version: '14' + - name: Restore cache + uses: actions/cache@v3.3.1 + with: + key: v10-deps-${{ hashFiles('yarn.lock') }} + path: | + ./.cache + **/node_modules + - name: Run UI test + run: cd src && yarn chromatic --project-token $CHROMATIC_APP_CODE --exit-zero-on-changes \ No newline at end of file diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 000000000..3bcb2062e --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,29 @@ +name: dpc-sdp/ripple/create-release +on: + workflow_call: + inputs: + canary-prerelease: + type: boolean + default: false +jobs: + create-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3.5.0 + - name: Restore cache + uses: actions/cache@v3.3.1 + with: + key: v10-deps-${{ hashFiles('yarn.lock') }} + path: | + ./.cache + **/node_modules + - name: Authenticate with registry + run: |- + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc + git update-index --assume-unchanged .npmrc + - name: Publish pre-release packages to NPM + if: inputs.canary-prerelease == true + run: npx lerna publish from-package --canary --force-publish --no-push --dist-tag dev --yes --no-verify-access + - name: Publish packages to NPM + if: inputs.canary-prerelease == false + run: npx lerna publish from-package --force-publish --yes --no-verify-access \ No newline at end of file diff --git a/.github/workflows/nightwatch.yml b/.github/workflows/nightwatch.yml new file mode 100644 index 000000000..159462d18 --- /dev/null +++ b/.github/workflows/nightwatch.yml @@ -0,0 +1,72 @@ +name: dpc-sdp/ripple/nightwatch +on: + workflow_dispatch: + inputs: + e2e: + type: boolean + required: true + e2e_project: + type: string + required: true + e2e_be_url: + type: string + e2e_fe_url: + type: string +jobs: + e2e_be: + if: inputs.e2e + uses: dpc-sdp/github-actions/.github/workflows/run_e2e_be.yml@main + secrets: inherit + with: + tags: "(@core or @${{ inputs.e2e_project }}) and @regression" + be_url: ${{ inputs.e2e_be_url }} + project: ${{ inputs.e2e_project }} + browser: 'chrome' + test_id: 'fixture' + test_type: ':nightwatch:' + runner: 'ubuntu-latest' + e2e_fe_smoke: + if: inputs.e2e + uses: dpc-sdp/github-actions/.github/workflows/run_e2e_fe.yml@main + secrets: inherit + with: + tags: "(@smoke and @core) or (@smoke and @${{ inputs.e2e_project }})" + be_url: ${{ inputs.e2e_be_url }} + fe_url: ${{ inputs.e2e_fe_url }} + project: ${{ inputs.e2e_project }} + browser: 'chrome' + test_id: 'fixture' + test_type: ':nightwatch:' + runner: 'ubuntu-latest' + e2e_fe_chrome: + needs: + - e2e_be + - e2e_fe_smoke + if: inputs.e2e + uses: dpc-sdp/github-actions/.github/workflows/run_e2e_fe.yml@main + secrets: inherit + with: + tags: "(@core or @${{ inputs.e2e_project }}) and @regression and not @mobile" + be_url: ${{ inputs.e2e_be_url }} + fe_url: ${{ inputs.e2e_fe_url }} + project: ${{ inputs.e2e_project }} + browser: 'chrome' + test_id: 'fixture' + test_type: ':nightwatch:' + runner: 'ubuntu-latest' + e2e_fe_android: + needs: + - e2e_be + - e2e_fe_smoke + if: inputs.e2e + uses: dpc-sdp/github-actions/.github/workflows/run_e2e_fe.yml@main + secrets: inherit + with: + tags: "(@core or @${{ inputs.e2e_project }}) and @regression and not @desktop" + be_url: ${{ inputs.e2e_be_url }} + fe_url: ${{ inputs.e2e_fe_url }} + project: ${{ inputs.e2e_project }} + browser: 'androidChrome' + test_id: 'fixture' + test_type: ':nightwatch:' + runner: 'ubuntu-latest' diff --git a/.github/workflows/publish-to-npm.yml b/.github/workflows/publish-to-npm.yml new file mode 100644 index 000000000..61209a1c4 --- /dev/null +++ b/.github/workflows/publish-to-npm.yml @@ -0,0 +1,53 @@ +name: dpc-sdp/ripple/publish-to-npm +on: + push: + branches: + # Uncomment below once testing has been completed and we are ready to publish using this workflow + #- master + - 'github-action/disable-workflow' +jobs: + build: + uses: ./.github/workflows/build.yml + test: + needs: + - build + uses: ./.github/workflows/test.yml + confirm-release: + environment: + name: approval + runs-on: ubuntu-latest + needs: + - test + steps: + - run: echo 'approved' + create-release: + needs: + - confirm-release + uses: ./.github/workflows/create-release.yml + tag-release: + needs: + - create-release + permissions: + contents: write + uses: ./.github/workflows/tag-release.yml + create-release-notes: + runs-on: ubuntu-latest + needs: + - tag-release + permissions: + contents: write + steps: + - uses: actions/checkout@v3.5.0 + - name: Restore cache + uses: actions/cache@v3.3.1 + with: + key: v10-deps-${{ hashFiles('yarn.lock') }} + path: | + ./.cache + **/node_modules + - name: Install github-release-notes package + run: yarn add -D -W github-release-notes + - name: Generate release notes and publish to GitHub + run: |- + PACKAGE_VERSION=$(node -pe "require('./lerna.json')['version']") + npx gren release --data-source=commits --tags=v$PACKAGE_VERSION --override --token ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml new file mode 100644 index 000000000..78c985593 --- /dev/null +++ b/.github/workflows/tag-release.yml @@ -0,0 +1,19 @@ +name: dpc-sdp/ripple/tag-release +on: + workflow_call: +jobs: + tag-release: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3.5.0 + - name: Git tag the release with the `lerna.json` version number + run: |- + PACKAGE_VERSION=$(node -pe "require('./lerna.json')['version']") + git tag v$PACKAGE_VERSION + - name: Push git tag to the remote repository + run: |- + PACKAGE_VERSION=$(node -pe "require('./lerna.json')['version']") + echo $PACKAGE_VERSION + git push -q https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git v$PACKAGE_VERSION \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..7682cd127 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,34 @@ +name: dpc-sdp/ripple/test +on: + workflow_call: +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3.5.0 + - uses: actions/setup-node@v3.6.0 + with: + node-version: '14' + - name: Restore cache + uses: actions/cache@v3.3.1 + with: + key: v10-deps-${{ hashFiles('yarn.lock') }} + path: | + ./.cache + **/node_modules + - name: Lint code. + run: yarn lint --format ./node_modules/eslint-junit/index.js + env: + ESLINT_JUNIT_OUTPUT: "./test-results/lint/eslint.xml" + - name: Unit tests + run: yarn test:unit --ci --runInBand --reporters=default --reporters=jest-junit + env: + JEST_JUNIT_OUTPUT_DIR: test-results/unit/ + - name: Upload test results + uses: actions/upload-artifact@v3.1.1 + with: + name: Test results + path: | + test-results + examples/reference/test/integration/videos + examples/reference/test/integration/screenshots \ No newline at end of file diff --git a/scripts/trigger-e2e.sh b/scripts/trigger-e2e.sh index 39a719223..af282f6ac 100644 --- a/scripts/trigger-e2e.sh +++ b/scripts/trigger-e2e.sh @@ -44,3 +44,21 @@ else } }' fi + +if [ -z $E2E_GITHUB_TOKEN ]; then + echo "Error: No E2E GitHub token found, end to end is not triggered. Please make sure E2E_GITHUB_TOKEN is set up." +else + # Trigger GitHub Action to run the workflow + curl --location --request POST "https://api.github.com/repos/dpc-sdp/ripple/actions/workflows/nightwatch.yml/dispatches" \ + --header "Authorization: Bearer $E2E_GITHUB_TOKEN" \ + --header 'Accept: application/vnd.github+json' \ + --data-raw '{ + "ref": "'"$BRANCH"'", + "inputs": { + "e2e": true, + "e2e_be_url": "'"$BE_URL"'", + "e2e_fe_url": "'"$FE_URL"'", + "e2e_project": "reference" + } + }' +fi