Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release setup #13

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/backstage-release.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prow publishes nightly releases, should we do the same for the NPM package?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely can. I don't think I would bind the NPM publish to the Prow's schedule then. Just a periodic (or, whenever something is pushed) that lives on Github actions.

Created #15, thanks for the idea.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this workflow, I think it's important that we get notifications for success / failure similar to https://cloud-native.slack.com/archives/C04LY4Y3EHF/p1698337431944799

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me do that as an improvement later, ok?

Created #14

Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Publish release on NPM

on:
# When manually triggered
workflow_dispatch:
Comment on lines +4 to +5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this manual trigger have inputs ? Otherwise actions/checkout@v4 will checkout the default branch main

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can select the branch in GitHub UI and then trigger the workflow. No need for any inputs. ...unless there's something I am missing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good now

inputs:
releaseName:
description: 'Release name, e.g. v1.2.3'
required: true

# When there's a release created
release:
types: [ published ]

jobs:
publish-release-on-npm:
name: Publish release on NPM
runs-on: ubuntu-latest

steps:
- name: Setup release name
run: |
if [ -z "${{ github.event.release.name }}" ]; then
echo "RELEASE_NAME=${{ github.event.inputs.releaseName }}" >> $GITHUB_ENV
else
echo "RELEASE_NAME=${{ github.event.release.name }}" >> $GITHUB_ENV
fi

- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'backstage/.nvmrc'
cache: 'yarn'
cache-dependency-path: 'backstage/yarn.lock'

- name: Print environment
run: |
node --version
yarn --version

- name: Print release name
run: |
echo "Release name: ${RELEASE_NAME}"

- name: Install dependencies
shell: bash
working-directory: ./backstage
run: yarn --prefer-offline --frozen-lockfile

- name: Install tooling
shell: bash
working-directory: ./backstage
run: npm install @backstage/cli -g

- name: Run tests
shell: bash
working-directory: ./backstage
run: |
export PATH="./node_modules/.bin/:$PATH"
yarn test
Comment on lines +58 to +63
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running tests here seems a good additional check, however, I think we need to run the tests before Prow publishes a release in the Prow jobs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #21


- name: Build
shell: bash
working-directory: ./backstage
run: |
export PATH="./node_modules/.bin/:$PATH"
yarn tsc
yarn build

- name: Update version of knative-event-mesh-backend plugin
shell: bash
working-directory: ./backstage/plugins/knative-event-mesh-backend
run: |
export PATH="./node_modules/.bin/:$PATH"
yarn version --new-version ${RELEASE_NAME} --no-git-tag-version

- name: Publish knative-event-mesh-backend plugin
uses: JS-DevTools/npm-publish@v2
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
package: backstage/plugins/knative-event-mesh-backend
9 changes: 6 additions & 3 deletions .github/workflows/backstage-unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Backstage unit tests

on:
push:
branches:
- main
pull_request:
branches:
- main
Expand All @@ -12,6 +9,7 @@ jobs:
unit-tests:
name: Test
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -23,6 +21,11 @@ jobs:
cache: 'yarn'
cache-dependency-path: 'backstage/yarn.lock'

- name: Print environment
run: |
node --version
yarn --version

- name: Install dependencies
shell: bash
working-directory: ./backstage
Expand Down
2 changes: 1 addition & 1 deletion backstage/lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"packages": ["packages/*", "plugins/*"],
"npmClient": "yarn",
"version": "0.1.0",
"version": "0.0.0-nightly",
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}
2 changes: 1 addition & 1 deletion backstage/packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@backstage/plugin-search-backend-module-techdocs": "^0.1.11",
"@backstage/plugin-search-backend-node": "^1.2.11",
"@backstage/plugin-techdocs-backend": "^1.9.0",
"@knative-extensions/plugin-knative-event-mesh-backend": "^0.1.0",
"@knative-extensions/plugin-knative-event-mesh-backend": "0.0.0-nightly",
"app": "link:../app",
"better-sqlite3": "^9.0.0",
"dockerode": "^3.3.1",
Expand Down
4 changes: 4 additions & 0 deletions backstage/plugins/knative-event-mesh-backend/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# keep this file so that npm doesn't use the .gitignore file
src/
.eslintrc.js
app-config.yaml
4 changes: 2 additions & 2 deletions backstage/plugins/knative-event-mesh-backend/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@knative-extensions/plugin-knative-event-mesh-backend",
"version": "0.1.0",
"version": "0.0.0-nightly",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
"private": true,
"private": false,
"publishConfig": {
"access": "public",
"main": "dist/index.cjs.js",
Expand Down
2 changes: 1 addition & 1 deletion backstage/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7831,7 +7831,7 @@
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb"
integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==

"@types/react-dom@*", "@types/react-dom@<18.0.0":
"@types/react-dom@*", "@types/react-dom@<18.0.0", "@types/react-dom@^17":
version "17.0.25"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.25.tgz#e0e5b3571e1069625b3a3da2b279379aa33a0cb5"
integrity sha512-urx7A7UxkZQmThYA4So0NelOVjx3V4rNFVJwp0WZlbIK5eM4rNJDiN3R/E9ix0MBh6kAEojk/9YL+Te6D9zHNA==
Expand Down
52 changes: 52 additions & 0 deletions hack/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

# Copyright 2023 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Documentation about this script and how to use it can be found
# at https://github.com/knative/test-infra/tree/master/ci

source $(dirname $0)/../vendor/knative.dev/hack/release.sh

Check failure on line 20 in hack/release.sh

View workflow job for this annotation

GitHub Actions / style / suggester / shell

[shellcheck (suggestion)] reported by reviewdog 🐶 Raw Output: hack/release.sh:20:-source $(dirname $0)/../vendor/knative.dev/hack/release.sh hack/release.sh:20:+source $(dirname "$0")/../vendor/knative.dev/hack/release.sh

export GO111MODULE=on

# Yaml files to generate, and the source config dir for them.
declare -A COMPONENTS
COMPONENTS=(
["eventmesh.yaml"]="backends/config/100-eventmesh"
)
readonly COMPONENTS

function build_release() {
# Update release labels if this is a tagged release
if [[ -n "${TAG}" ]]; then
echo "Tagged release, updating release labels to app.kubernetes.io/version: \"${TAG}\""
LABEL_YAML_CMD=(sed -e "s|app.kubernetes.io/version: devel|app.kubernetes.io/version: \"${TAG}\"|")
else
echo "Untagged release, will NOT update release labels"
LABEL_YAML_CMD=(cat)
fi

local all_yamls=()
for yaml in "${!COMPONENTS[@]}"; do
local config="${COMPONENTS[${yaml}]}"
echo "Building Knative Backstage Backends - ${config}"
ko resolve -j 1 ${KO_FLAGS} -f ${config}/ | "${LABEL_YAML_CMD[@]}" > ${yaml}

Check failure on line 45 in hack/release.sh

View workflow job for this annotation

GitHub Actions / style / suggester / shell

[shellcheck (suggestion)] reported by reviewdog 🐶 Raw Output: hack/release.sh:45:- ko resolve -j 1 ${KO_FLAGS} -f ${config}/ | "${LABEL_YAML_CMD[@]}" > ${yaml} hack/release.sh:45:+ ko resolve -j 1 "${KO_FLAGS}" -f "${config}"/ | "${LABEL_YAML_CMD[@]}" > "${yaml}"
all_yamls+=(${yaml})
done

ARTIFACTS_TO_PUBLISH="${all_yamls[@]}"
}

main $@
29 changes: 29 additions & 0 deletions test/presubmit-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# Copyright 2023 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This script runs the presubmit tests; it is started by prow for each PR.
# For convenience, it can also be executed manually.
# Running the script without parameters, or with the --all-tests
# flag, causes all tests to be executed, in the right order.
# Use the flags --build-tests, --unit-tests and --integration-tests
# to run a specific set of tests.

export GO111MODULE=on
export DISABLE_MD_LINTING=1

source $(dirname "$0")/../vendor/knative.dev/hack/presubmit-tests.sh

main $@
Loading