Skip to content

Commit

Permalink
dso-toolkit#2568 [Task] Build: GitHub Actions pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
tfrijsewijk committed Mar 15, 2024
1 parent baebb6a commit d55f122
Show file tree
Hide file tree
Showing 51 changed files with 248 additions and 488 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
**/dist
**/www

.git
.nx
.dockerignore
Dockerfile
.travis.yml
travis
.github

.yarn/cache
.yarn/install-state.gz
Expand Down
93 changes: 93 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: CI
on: [push]

jobs:
CI:
name: lint, build, test, deploy
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
name: Log in to GitHub Container Registry
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/github-script@v7
with:
script: |
if (context.eventName === 'push') {
const [branch, type] = context.ref.split('/').reverse();
if (type === 'heads' && branch.lastIndexOf('#') === 0) {
core.exportVariable('DT_REF', branch.replace(/#/, '_'));
}
else if (type === 'heads' && branch === 'master') {
core.exportVariable('DT_REF', 'master');
}
else if (type === 'tags' && branch[0] === 'v') {
core.exportVariable('DT_REF', branch.substring(1));
core.exportVariable('DT_DIST_TAG', 'latest');
}
}
- name: Output DT_REF
run: echo $DT_REF;
- uses: docker/build-push-action@v5
name: Build and push Docker image
with:
push: true
tags: ghcr.io/tfrijsewijk/dso-toolkit:${{ env.DT_REF }}
context: .
cache-from: |
ghcr.io/tfrijsewijk/dso-toolkit:${{ env.DT_REF }}
cache-to: type=inline
build-args: |
CI
DT_REF
- name: "Prepare Cypress Parallel weights file"
run: mkdir --verbose --parents ${{ github.workspace }}/storybook/cypress-parallel
- name: "Cache: Cypress Parallel weights file"
id: cypress-parallel-weights-file-cache
uses: actions/cache@v4
with:
key: weights-file
path: ${{ github.workspace }}/storybook/cypress-parallel/parallel-weights.json
- name: e2e tests
uses: addnab/docker-run-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
image: ghcr.io/tfrijsewijk/dso-toolkit:${{ env.DT_REF }}
options: --env CI
--env DT_REF
--volume ${{ github.workspace }}/storybook/cypress-parallel:/usr/src/app/storybook/cypress-parallel
run: yarn e2e
- uses: addnab/docker-run-action@v3
name: Deploy
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
image: ghcr.io/tfrijsewijk/dso-toolkit:${{ env.DT_REF }}
options: --env CI
--env DT_REF
--env DT_DIST_TAG
--env DT_PRIVATE_KEY_BASE64
--env DT_DEPLOY_HOST
--env DT_DEPLOY_PORT
--env DT_DEPLOY_USER
--env DT_DEPLOY_ROOT
--env DT_DEPLOY_NPM_TOKEN
--env GITHUB_TOKEN
run: bash deploy.sh
env:
DT_PRIVATE_KEY_BASE64: ${{ secrets.DT_PRIVATE_KEY_BASE64 }}
DT_DEPLOY_HOST: ${{ secrets.DT_DEPLOY_HOST }}
DT_DEPLOY_PORT: ${{ secrets.DT_DEPLOY_PORT }}
DT_DEPLOY_USER: ${{ secrets.DT_DEPLOY_USER }}
DT_DEPLOY_ROOT: ${{ secrets.DT_DEPLOY_ROOT }}
DT_DEPLOY_NPM_TOKEN: ${{ secrets.DT_DEPLOY_NPM_TOKEN }}
16 changes: 16 additions & 0 deletions .github/workflows/danger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Danger
on: [pull_request]
jobs:
Danger:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Danger
run: |
npm install --global typescript@<5.3.0 danger@11.3.1
danger ci --failOnErrors
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a

## Next

### Tasks
* Build: GitHub Actions pipeline ([#2568](https://github.com/dso-toolkit/dso-toolkit/issues/2568))

## 🦩 62.15.0 - 12-03-2024

### Added
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ RUN yarn dedupe --check
RUN (yarn npm audit --all --recursive || true)
RUN yarn lint

ARG TRAVIS_BRANCH
ARG TRAVIS_TAG
ARG DT_REF

RUN yarn build

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![This project is using Percy.io for visual regression testing.](https://percy.io/static/images/percy-badge.svg)](https://percy.io/dso-toolkit/dso-toolkit) [![npm version](http://img.shields.io/npm/v/dso-toolkit.svg)](https://npmjs.org/package/dso-toolkit "View this project on npm") [![Build status master branch](https://img.shields.io/travis/com/dso-toolkit/dso-toolkit/master)](https://travis-ci.com/dso-toolkit/dso-toolkit)
[![npm version](http://img.shields.io/npm/v/dso-toolkit.svg)](https://npmjs.org/package/dso-toolkit "View this project on npm") ![master branch build status](https://github.com/tfrijsewijk/dso-toolkit/actions/workflows/ci.yml/badge.svg?branch=master)

- [Slack chat](https://dso-toolkit.slack.com/)
- [Slack chat invite link](https://join.slack.com/t/dso-toolkit/shared_invite/zt-58125gbo-FtPAARcnU47rMgkT7KWikA)
Expand Down
38 changes: 19 additions & 19 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@ mkdir --parents ~/.ssh
cat known_hosts >> ~/.ssh/known_hosts
echo -e "Host ${DT_DEPLOY_HOST}\n\tCheckHostIP no\n" >> ~/.ssh/config

rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive ./storybook/www/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/storybook.dso-toolkit.nl/www/${TRAVIS_BRANCH/\#/_}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive ./packages/react/www/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/react.dso-toolkit.nl/www/${TRAVIS_BRANCH/\#/_}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive ./angular-workspace/www/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/angular.dso-toolkit.nl/www/${TRAVIS_BRANCH/\#/_}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive ./website/www/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/dso-toolkit.nl/www/${TRAVIS_BRANCH/\#/_}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive --exclude 'node_modules' ./packages/dso-toolkit/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/cdn.dso-toolkit.nl/www/dso-toolkit/${TRAVIS_BRANCH/\#/_}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive --exclude 'node_modules' ./packages/core/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/cdn.dso-toolkit.nl/www/@dso-toolkit/core/${TRAVIS_BRANCH/\#/_}

if [ -n "$TRAVIS_TAG" ]
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive ./storybook/www/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/storybook.dso-toolkit.nl/www/${DT_REF}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive ./packages/react/www/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/react.dso-toolkit.nl/www/${DT_REF}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive ./angular-workspace/www/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/angular.dso-toolkit.nl/www/${DT_REF}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive ./website/www/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/dso-toolkit.nl/www/${DT_REF}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive --exclude 'node_modules' ./packages/dso-toolkit/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/cdn.dso-toolkit.nl/www/dso-toolkit/${DT_REF}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive --exclude 'node_modules' ./packages/core/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/cdn.dso-toolkit.nl/www/@dso-toolkit/core/${DT_REF}

if [[ -n ${DT_DIST_TAG+x} && $DT_DIST_TAG == "latest" ]]
then
yarn config set npmAuthToken "${DT_DEPLOY_NPM_TOKEN}"
npm config set //registry.npmjs.org/:_authToken ${DT_DEPLOY_NPM_TOKEN}

yarn workspace @dso-toolkit/core version ${TRAVIS_TAG:1} --immediate
yarn workspace @dso-toolkit/react version ${TRAVIS_TAG:1} --immediate
yarn workspace dso-toolkit version ${TRAVIS_TAG:1} --immediate
yarn workspace @dso-toolkit/core version ${DT_REF} --immediate
yarn workspace @dso-toolkit/react version ${DT_REF} --immediate
yarn workspace dso-toolkit version ${DT_REF} --immediate

yarn workspace dso-toolkit npm publish --access public
yarn workspace @dso-toolkit/core npm publish --access public
yarn workspace @dso-toolkit/react npm publish --access public

cd angular-workspace/dist/component-library
npm version ${TRAVIS_TAG:1}
npm version ${DT_REF}
npm publish
cd ../../..

gh release create ${TRAVIS_TAG} --generate-notes --verify-tag
gh release create v${DT_REF} --generate-notes --verify-tag

rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive ./storybook/www/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/storybook.dso-toolkit.nl/www/${TRAVIS_TAG:1}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive ./packages/react/www/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/react.dso-toolkit.nl/www/${TRAVIS_TAG:1}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive ./angular-workspace/www/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/angular.dso-toolkit.nl/www/${TRAVIS_TAG:1}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive ./website/www/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/dso-toolkit.nl/www/${TRAVIS_TAG:1}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive --exclude 'node_modules' ./packages/dso-toolkit/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/cdn.dso-toolkit.nl/www/dso-toolkit/${TRAVIS_TAG:1}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive --exclude 'node_modules' ./packages/core/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/cdn.dso-toolkit.nl/www/@dso-toolkit/core/${TRAVIS_TAG:1}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive ./storybook/www/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/storybook.dso-toolkit.nl/www/${DT_REF}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive ./packages/react/www/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/react.dso-toolkit.nl/www/${DT_REF}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive ./angular-workspace/www/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/angular.dso-toolkit.nl/www/${DT_REF}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive ./website/www/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/dso-toolkit.nl/www/${DT_REF}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive --exclude 'node_modules' ./packages/dso-toolkit/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/cdn.dso-toolkit.nl/www/dso-toolkit/${DT_REF}
rsync --rsh "ssh -p ${DT_DEPLOY_PORT}" --delete --recursive --exclude 'node_modules' ./packages/core/ ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST}:${DT_DEPLOY_ROOT}/cdn.dso-toolkit.nl/www/@dso-toolkit/core/${DT_REF}
fi

ssh -p ${DT_DEPLOY_PORT} ${DT_DEPLOY_USER}@${DT_DEPLOY_HOST} "cd ${DT_DEPLOY_ROOT}/webhooks.dso-toolkit.nl && powershell -Command \"npm run update-versions\""
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"axe-core": "^4.8.2",
"concurrently": "^8.2.2",
"cpy-cli": "^5.0.0",
"danger": "^11.3.0",
"danger": "11.3.1",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-lit": "^1.10.1",
Expand Down
13 changes: 2 additions & 11 deletions packages/dso-toolkit/gulp/build-styling.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,8 @@ function getVersion() {
return process.env.DT_VERSION;
}

if (process.env.CI) {
if (typeof process.env.TRAVIS_TAG === "string" && process.env.TRAVIS_TAG[0] === "v") {
return process.env.TRAVIS_TAG.substring(1);
}

if (
typeof process.env.TRAVIS_BRANCH === "string" &&
(process.env.TRAVIS_BRANCH[0] === "#" || process.env.TRAVIS_BRANCH === "master")
) {
return process.env.TRAVIS_BRANCH.replace(/#/, "_");
}
if (process.env.CI && process.env.DT_REF) {
return process.env.DT_REF;
}

return undefined;
Expand Down
12 changes: 2 additions & 10 deletions storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,8 @@ import { resolve, dirname, parse, join } from "path";
const testStoryStoryV7 = false;

function getVersion() {
if (process.env.CI) {
if (typeof process.env.TRAVIS_TAG === "string" && process.env.TRAVIS_TAG[0] === "v") {
return process.env.TRAVIS_TAG.substring(1);
}
if (
typeof process.env.TRAVIS_BRANCH === "string" &&
(process.env.TRAVIS_BRANCH[0] === "#" || process.env.TRAVIS_BRANCH === "master")
) {
return process.env.TRAVIS_BRANCH.replace(/#/, "_");
}
if (process.env.CI && process.env.DT_REF) {
return process.env.DT_REF;
}

return undefined;
Expand Down
3 changes: 0 additions & 3 deletions storybook/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { defineConfig } from "cypress";

export default defineConfig({
env: {
PERCY: !!process.env.PERCY_TOKEN,
},
e2e: {
setupNodeEvents(_on, _config) {
// This method is needed for Cypress /Th
Expand Down
2 changes: 1 addition & 1 deletion storybook/cypress/e2e/accordion.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe("Accordion", () => {
});

it("should be accessible", () => {
cy.percySnapshot();
// cy.percySnapshot();

cy.injectAxe();
cy.checkA11y("dso-accordion");
Expand Down
2 changes: 1 addition & 1 deletion storybook/cypress/e2e/action-list.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ describe("ActionList", () => {
});

it("screenshot", () => {
cy.percySnapshot();
// cy.percySnapshot();
});
});
2 changes: 1 addition & 1 deletion storybook/cypress/e2e/alert.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("Alert", () => {
.invoke("prop", "icon")
.should("equal", icon);

cy.percySnapshot();
// cy.percySnapshot();
});
}
});
2 changes: 1 addition & 1 deletion storybook/cypress/e2e/autosuggest.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("Autosuggest", () => {
cy.checkA11y("dso-autosuggest");
cy.get("@listbox").get("li[role='option']").should("have.length", 10);

cy.percySnapshot();
// cy.percySnapshot();
});

it("should regexp-escape suggestions", () => {
Expand Down
2 changes: 1 addition & 1 deletion storybook/cypress/e2e/date-picker-legacy.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("Date Picker (Legacy)", () => {
cy.get(`label[for="${id}"]`).should("exist").and("not.be.empty");
});

cy.percySnapshot();
// cy.percySnapshot();
});

it("should have focus trap", () => {
Expand Down
2 changes: 1 addition & 1 deletion storybook/cypress/e2e/date-picker.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("Date Picker", () => {
});

cy.checkA11y("#root-inner");
cy.percySnapshot();
// cy.percySnapshot();
});

it("should emit dsoDateChange event", () => {
Expand Down
2 changes: 1 addition & 1 deletion storybook/cypress/e2e/dropdown-menu.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("Dropdown menu - anchors", () => {
});

it("should open and close on button click", () => {
cy.percySnapshot();
// cy.percySnapshot();

cy.get("@options").should("not.be.visible");

Expand Down
6 changes: 4 additions & 2 deletions storybook/cypress/e2e/header.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ describe("Header", () => {

it("should be accessible", () => {
cy.checkA11y("dso-header");
cy.percySnapshot().get("dso-header").invoke("attr", "useDropDownMenu", "always").checkA11y("dso-header");
cy.percySnapshot(`${Cypress.currentTest.title}" -- dropdown menu`)
// cy.percySnapshot()
cy.get("dso-header").invoke("attr", "useDropDownMenu", "always").checkA11y("dso-header");
cy
// .percySnapshot(`${Cypress.currentTest.title}" -- dropdown menu`)
.viewport(400, 600)
.get("dso-header")
.invoke("attr", "useDropDownMenu", "auto")
Expand Down
4 changes: 2 additions & 2 deletions storybook/cypress/e2e/helpcenter-panel.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("Helpcenter panel", () => {
});

it("should open panel on help button click", () => {
cy.percySnapshot();
// cy.percySnapshot();

cy.get("@iframeContainer")
.should("have.class", "close")
Expand All @@ -55,7 +55,7 @@ describe("Helpcenter panel", () => {
.get("@openButton")
.should("have.class", "open");

cy.percySnapshot(`${Cypress.currentTest.title}" -- opened`);
// cy.percySnapshot(`${Cypress.currentTest.title}" -- opened`);
});

it.skip("should not load iframe when panel is closed", () => {
Expand Down
2 changes: 1 addition & 1 deletion storybook/cypress/e2e/image-overlay.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("Image Overlay", () => {

it("should open and close overlay", () => {
openOverlay();
cy.percySnapshot();
// cy.percySnapshot();
cy.get("dso-image-overlay").shadow().find("button.close").click();
cy.get("dso-image-overlay").shadow().find(".wrapper > img").should("not.exist");
});
Expand Down
Loading

0 comments on commit d55f122

Please sign in to comment.