Skip to content

Commit

Permalink
[DEVOPS-248] Migrate CircleCI to Github actions (#1313)
Browse files Browse the repository at this point in the history
* Migrating from CircleCI to GitHub Actions

* Update env variable to use secrets

* Revert "Update env variable to use secrets"

This reverts commit 40de4af.

* Fixed typo

* Removed e2e release branch logic in nightwatch workflow

* Adding push event to create workflow dispatch

* Updated branch to main for reusable workflows

* Added runner inputs to use ubuntu-latest

* Added missing closed bracket

* Revert "Adding push event to create workflow dispatch"

This reverts commit e1c0615.

* Temporary disabled workflows by updating the trigger event to branches that do not exist

---------

Co-authored-by: Tim Yao <[email protected]>
  • Loading branch information
MarkCalvert and tim-yao authored Sep 20, 2023
1 parent 803a43c commit 0ee3c05
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
- uses: actions/[email protected]
with:
node-version: '14'
- name: Restore cache
uses: actions/[email protected]
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
26 changes: 26 additions & 0 deletions .github/workflows/canary-npm-release.yml
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions .github/workflows/commit.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
fetch-depth: 0 # 👈 Required to retrieve git history
- uses: actions/[email protected]
with:
node-version: '14'
- name: Restore cache
uses: actions/[email protected]
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
29 changes: 29 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
- name: Restore cache
uses: actions/[email protected]
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
72 changes: 72 additions & 0 deletions .github/workflows/nightwatch.yml
Original file line number Diff line number Diff line change
@@ -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'
53 changes: 53 additions & 0 deletions .github/workflows/publish-to-npm.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
- name: Restore cache
uses: actions/[email protected]
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 }}
19 changes: 19 additions & 0 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
- 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
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: dpc-sdp/ripple/test
on:
workflow_call:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: '14'
- name: Restore cache
uses: actions/[email protected]
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/[email protected]
with:
name: Test results
path: |
test-results
examples/reference/test/integration/videos
examples/reference/test/integration/screenshots
18 changes: 18 additions & 0 deletions scripts/trigger-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0ee3c05

Please sign in to comment.