Skip to content

Commit

Permalink
cd pipeline (#35)
Browse files Browse the repository at this point in the history
Now we have also CD pipeline that can publish packages and create a release!

Also
- bump score-card version (updated url in package)
- added DCO
- badges for CI/CD pipeline in README
- more scripts from backstage repo to lint&check sources
  • Loading branch information
jvilimek authored Sep 20, 2022
1 parent 88389a6 commit 201ac64
Show file tree
Hide file tree
Showing 19 changed files with 1,279 additions and 92 deletions.
5 changes: 0 additions & 5 deletions .changeset/popular-queens-ring.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/swift-moose-cheat.md

This file was deleted.

147 changes: 147 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: 'CD pipeline'

on:
workflow_dispatch:
inputs:
create_release:
description: 'Create release'
required: true
type: boolean
default: 'true'
publish_packages:
description: 'Publish npm packages'
required: true
type: boolean
default: 'true'
push:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

outputs:
needs_release: ${{ steps.release_check.outputs.needs_release }}

strategy:
matrix:
node-version: [16.x]

env:
CI: true
NODE_OPTIONS: --max-old-space-size=4096

steps:
- name: Check of github.event.before
if: ${{ !github.event.inputs.create_release && !github.event.inputs.publish_packages }}
run: if [ '${{ github.event.before }}' = '0000000000000000000000000000000000000000' ]; then echo "::warning title=Missing github.event.before::You are running this CD workflow on a newly created branch. Release won't be created..."; fi

- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/ # Needed for auth

- name: yarn install
uses: backstage/actions/[email protected]
with:
cache-prefix: ${{ runner.os }}-v${{ matrix.node-version }}

- name: Fetch previous commit for release check
if: ${{ github.event.before != '0000000000000000000000000000000000000000' }}
run: git fetch origin '${{ github.event.before }}'

- name: Check if release
id: release_check
if: ${{ github.event.before != '0000000000000000000000000000000000000000' }}
run: node scripts/check-if-release.js
env:
COMMIT_SHA_BEFORE: '${{ github.event.before }}'

- name: validate config
run: yarn backstage-cli config:check --lax

- name: lint
run: yarn backstage-cli repo lint

- name: type checking and declarations
run: yarn tsc:full

- name: build
run: yarn backstage-cli repo build --all

- name: verify type dependencies
run: yarn lint:type-deps

- name: test
run: |
yarn lerna -- run test -- --coverage --runInBand
# A separate release build that is only run for commits that are the result of merging the "Version Packages" PR
# We can't re-use the output from the above step, but we'll have a guaranteed node_modules cache and
# only run the build steps that are necessary for publishing
release:
needs: build

if: needs.build.outputs.needs_release == 'true' || github.event.inputs.create_release || github.event.inputs.publish_packages

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

env:
CI: 'true'
NODE_OPTIONS: --max-old-space-size=4096

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/ # Needed for auth

- name: yarn install
uses: backstage/actions/[email protected]
with:
cache-prefix: ${{ runner.os }}-v${{ matrix.node-version }}

- name: build type declarations
run: yarn tsc:full

- name: build packages
run: yarn backstage-cli repo build

# Publishes current version of packages that are not already present in the registry
- name: publish
if: needs.build.outputs.needs_release == 'true' || github.event.inputs.publish_packages
run: |
if [ -f ".changeset/pre.json" ]; then
yarn lerna -- publish from-package --yes --dist-tag next
else
yarn lerna -- publish from-package --yes
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# Grabs the version in the root package.json and creates a tag on GitHub
- name: Create a release tag
id: create_tag
if: needs.build.outputs.needs_release == 'true' || github.event.inputs.create_release
run: node scripts/create-release-tag.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Convert the newly created tag into a release with changelog information
- name: Create release on GitHub
if: needs.build.outputs.needs_release == 'true' || github.event.inputs.create_release
run: node scripts/create-github-release.js ${{ steps.create_tag.outputs.tag_name }} 1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
registry=https://registry.npmjs.org/
always-auth=false
engine-strict=true
37 changes: 37 additions & 0 deletions DCO
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or

(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or

(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.

(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Oriflame Backstage plugins.

[![CI pipeline](https://github.com/Oriflame/backstage-plugins/actions/workflows/ci.yml/badge.svg)](https://github.com/Oriflame/backstage-plugins/actions/workflows/ci.yml)

[![CD pipeline](https://github.com/Oriflame/backstage-plugins/actions/workflows/cd.yml/badge.svg)](https://github.com/Oriflame/backstage-plugins/actions/workflows/cd.yml)

## Getting started

You may find our plugins in the `./plugins` folder. You may start each plugin in isolated mode (navigate to the plugin folder and run `yarn dev` or `yarn start:dev`, see respective README). You may start also the simple backstage host with the plugins integrated via `yarn dev` (in root folder). You may run `yarn test` to run jest tests. For more information see [CONTRIBUTING.md](./CONTRIBUTING.md).
Expand Down
143 changes: 73 additions & 70 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,72 +1,75 @@
{
"name": "ori-backstage-plugins",
"description": "Oriflame plugins for Backstage.",
"maintainers": [
"[email protected]",
"[email protected]",
"[email protected]"
"name": "ori-backstage-plugins",
"description": "Oriflame plugins for Backstage.",
"maintainers": [
"[email protected]",
"[email protected]",
"[email protected]"
],
"version": "0.1.5",
"private": true,
"engines": {
"node": "14 || 16"
},
"scripts": {
"dev": "concurrently \"yarn start\" \"yarn start-backend\" \"http-server -p 8090 --cors 2>&1\"",
"start": "yarn workspace app start",
"start-backend": "yarn workspace backend start",
"build": "backstage-cli repo build --all",
"tsc": "tsc",
"tsc:full": "backstage-cli clean && tsc --skipLibCheck true --incremental false",
"clean": "backstage-cli clean && lerna run clean",
"diff": "lerna run diff --",
"test": "backstage-cli test",
"test:all": "lerna run test -- --coverage",
"test:e2e": "yarn workspace app cypress run",
"lint": "backstage-cli repo lint --since origin/main",
"lint:all": "backstage-cli repo lint",
"lint:type-deps": "node scripts/check-type-dependencies.js",
"create-plugin": "backstage-cli create-plugin --scope ori --no-private",
"remove-plugin": "backstage-cli remove-plugin",
"release": "node scripts/prepare-release.js && changeset version && yarn diff --yes && yarn prettier --write '{packages,plugins}/*/{package.json,CHANGELOG.md}' '.changeset/*.json' && yarn install",
"prettier:check": "prettier --check .",
"lerna": "lerna",
"lock:check": "yarn-lock-check"
},
"workspaces": {
"packages": [
"packages/*",
"plugins/*"
]
},
"resolutions": {
"@types/react": "^17",
"@types/react-dom": "^17"
},
"dependencies": {
"@changesets/cli": "2.24.4"
},
"devDependencies": {
"@backstage/cli": "0.18.1",
"@spotify/prettier-config": "14.1.0",
"@types/webpack": "5.28.0",
"concurrently": "7.4.0",
"eslint-plugin-notice": "0.9.10",
"lerna": "5.5.1",
"prettier": "2.7.1",
"typescript": "4.8.3",
"@types/react": "17.0.50",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"prettier": "@spotify/prettier-config",
"lint-staged": {
"*.{js,jsx,ts,tsx,mjs,cjs}": [
"eslint --fix",
"prettier --write"
],
"version": "0.1.0",
"private": true,
"engines": {
"node": "14 || 16"
},
"scripts": {
"dev": "concurrently \"yarn start\" \"yarn start-backend\" \"http-server -p 8090 --cors 2>&1\"",
"start": "yarn workspace app start",
"start-backend": "yarn workspace backend start",
"build": "lerna run build",
"build-image": "yarn workspace backend build-image",
"tsc": "tsc",
"tsc:full": "tsc --skipLibCheck false --incremental false",
"clean": "backstage-cli clean && lerna run clean",
"diff": "lerna run diff --",
"test": "lerna run test --since origin/main -- --coverage --runInBand",
"test:all": "lerna run test -- --coverage --runInBand",
"test:e2e": "yarn workspace app cypress run",
"lint": "lerna run lint --since origin/main --",
"lint:all": "lerna run lint --",
"create-plugin": "backstage-cli create-plugin --scope ori --no-private",
"remove-plugin": "backstage-cli remove-plugin",
"release": "changeset version && yarn prettier --write '{packages,plugins}/*/{package.json,CHANGELOG.md}' && yarn install"
},
"workspaces": {
"packages": [
"packages/*",
"plugins/*"
]
},
"resolutions": {
"@types/react": "^17",
"@types/react-dom": "^17"
},
"dependencies": {
"@changesets/cli": "2.24.4"
},
"devDependencies": {
"@backstage/cli": "0.18.1",
"@spotify/prettier-config": "14.1.0",
"@types/webpack": "5.28.0",
"concurrently": "7.4.0",
"eslint-plugin-notice": "0.9.10",
"lerna": "5.5.1",
"prettier": "2.7.1",
"typescript": "4.8.3",
"@types/react": "17.0.50",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"prettier": "@spotify/prettier-config",
"lint-staged": {
"*.{js,jsx,ts,tsx,mjs,cjs}": [
"eslint --fix",
"prettier --write"
],
"*.{json,md}": [
"prettier --write"
],
"*.md": [
"node ./scripts/check-docs-quality"
]
}
}
"*.{json,md}": [
"prettier --write"
],
"*.md": [
"node ./scripts/check-docs-quality"
]
}
}
8 changes: 8 additions & 0 deletions packages/app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# app

## 0.4.1

### Patch Changes

- ac344f7: added e2e tests for scorecard plugin
- Updated dependencies [a4d022f]
- @oriflame/backstage-plugin-score-card@0.4.1

## 0.4.0

Initial version for plugins app host.
Loading

0 comments on commit 201ac64

Please sign in to comment.