Skip to content

Commit

Permalink
Add openshift specific files.
Browse files Browse the repository at this point in the history
  • Loading branch information
serverless-qe committed Oct 24, 2024
1 parent 781746a commit 85a43d8
Show file tree
Hide file tree
Showing 22 changed files with 814 additions and 246 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/backstage-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Backstage lint

on:
pull_request:
branches:
- 'release-*'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- 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: Install dependencies
shell: bash
working-directory: ./backstage
run: yarn --prefer-offline --frozen-lockfile

- name: Lint all code
shell: bash
working-directory: ./backstage
run: yarn backstage-cli repo lint
39 changes: 39 additions & 0 deletions .github/workflows/backstage-unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Backstage unit tests

on:
pull_request:
branches:
- 'release-*'

jobs:
unit-tests:
name: Test
runs-on: ubuntu-latest
steps:
- 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: Install dependencies
shell: bash
working-directory: ./backstage
run: yarn --prefer-offline --frozen-lockfile

- name: Run tests
shell: bash
working-directory: ./backstage
run: |
export PATH="./node_modules/.bin/:$PATH"
yarn test
24 changes: 24 additions & 0 deletions .github/workflows/go-unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Go unit tests

on:
pull_request:
branches:
- 'release-*'

jobs:
build:
name: go unit tests
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Test
run: |
go test -v -race ./...
170 changes: 170 additions & 0 deletions .github/workflows/release-plugins.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
name: Backstage plugin release

on:
pull_request:
branches:
- 'release-*'
paths:
- 'backstage/plugins/knative-event-mesh-backend/**'
push:
branches:
- 'release-*'
# Do not run on push to release-next branch. We don't want to publish the plugin on every push to release-next.
# It might be okay to do so, but sobranch tool doesn't work well with release-next branch name.
- '!release-next'
# Ideally, we would want to only publish the plugin on NPM when there's an actual code change in the plugin.
# However, using the path filters block workflow execution on initial branch creation.
# So, let's publish on every push to a release branch.
# see https://github.com/openshift-knative/backstage-plugins/pull/15#issuecomment-2333324099
# paths:
# - 'backstage/plugins/knative-event-mesh-backend/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
event_mesh_plugin:
- 'backstage/plugins/knative-event-mesh-backend/**'
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Checkout openshift-knative/hack
uses: actions/checkout@v4
with:
repository: 'openshift-knative/hack'
ref: 'main'
path: ./src/github.com/openshift-knative/hack

- name: Install sobranch
run: |
go install ./cmd/sobranch
working-directory: ./src/github.com/openshift-knative/hack

- name: Setup release name for release branch push
# do not run the step on PRs against release-next branch. run it on:
# PRs against release-* branches, push to release-* branches, and creation of release-* branches
if: github.event.created || steps.changes.outputs.event_mesh_plugin == 'true'
run: |
BRANCH=$(git rev-parse --abbrev-ref HEAD) #e.g. release-v1.33
echo "Release branch: ${BRANCH}"
SO_RELEASE_NAME=$( $(go env GOPATH)/bin/sobranch --upstream-version "${BRANCH}") # input format: "release-v1.11" or "release-1.11" or "v1.11" or "1.11"
# SO_RELEASE_NAME will be something like "release-1.33"
echo "SO_RELEASE_NAME: ${SO_RELEASE_NAME}"
# split the release name to get the version number
## e.g. release-1.33 -> 1.33
BASE_RELEASE_VERSION=${SO_RELEASE_NAME#*-}
echo "BASE_RELEASE_VERSION: ${BASE_RELEASE_VERSION}"
RELEASE_NAME="${BASE_RELEASE_VERSION}.0"
EXISTING_RELEASES=""
if EXISTING_RELEASES=$(npm view @openshift-knative/plugin-knative-event-mesh-backend versions --json); then
echo "Package information fetched successfully"
echo "Existing releases: ${EXISTING_RELEASES}"
PATCH_RELEASES=$(echo "${EXISTING_RELEASES}" | grep ${BASE_RELEASE_VERSION})
if [ -z "${PATCH_RELEASES}" ]; then
echo "No existing PATCH_RELEASES found for ${BASE_RELEASE_VERSION}"
echo "Going to publish a new .0 patch release"
RELEASE_NAME="${BASE_RELEASE_VERSION}.0"
else
echo "Existing PATCH_RELEASES found for ${BASE_RELEASE_VERSION}"
PATCH=$(echo "${PATCH_RELEASES}" | tail -1 | tr -d '"' | awk -F \. '{print $3+1}')
RELEASE_NAME="${BASE_RELEASE_VERSION}.${PATCH}"
fi
else
echo "Error fetching package information. Going to publish a new .0 patch release"
RELEASE_NAME="${BASE_RELEASE_VERSION}.0"
fi
echo "RELEASE_NAME: ${RELEASE_NAME}"
echo "RELEASE_NAME=${RELEASE_NAME}" >> $GITHUB_ENV
- 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: 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
- name: Build
shell: bash
working-directory: ./backstage
run: |
export PATH="./node_modules/.bin/:$PATH"
yarn tsc
yarn build:all
- name: Update version of knative-event-mesh-backend plugin
# do not run the step on PRs against release-next branch. run it on:
# PRs against release-* branches, push to release-* branches, and creation of release-* branches
if: github.event.created || steps.changes.outputs.event_mesh_plugin == 'true'
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: Prepack knative-event-mesh-backend plugin
shell: bash
working-directory: ./backstage/plugins/knative-event-mesh-backend
run: |
export PATH="./node_modules/.bin/:$PATH"
yarn prepack
- name: Publish knative-event-mesh-backend plugin
uses: JS-DevTools/npm-publish@v3
# do not run the step on PRs against release-next branch. run it on:
# PRs against release-* branches, push to release-* branches, and creation of release-* branches
if: github.event.created || steps.changes.outputs.event_mesh_plugin == 'true'
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
package: backstage/plugins/knative-event-mesh-backend
tag: latest

- name: Postpack knative-event-mesh-backend plugin
shell: bash
working-directory: ./backstage/plugins/knative-event-mesh-backend
run: |
export PATH="./node_modules/.bin/:$PATH"
yarn postpack
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#This makefile is used by ci-operator

CGO_ENABLED=0
GOOS=linux
BRANCH=
TEST=
IMAGE=
TEST_IMAGE_TAG ?= latest


test-e2e:
./openshift/e2e-tests.sh
.PHONY: test-e2e

# Generate an aggregated knative release yaml file, as well as a CI file with replaced image references
generate-release:
./openshift/release/generate-release.sh
.PHONY: generate-release
13 changes: 5 additions & 8 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Sponsored by the Eventing WG
# At least one WG lead from https://github.com/knative/community/blob/main/working-groups/WORKING-GROUPS.md#eventing
# must be in the "approvers" list.
# The OWNERS file is used by prow to automatically merge approved PRs.

approvers:
- technical-oversight-committee
- knative-release-leads
- eventing-writers
- backstage-plugins-writers
- eventing-approvers

reviewers:
- backstage-plugins-reviewers
- eventing-reviewers

Loading

0 comments on commit 85a43d8

Please sign in to comment.