-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic ci workflow and fixed problems with prettier. Change-Id: I329bee41fb078b6dbb31458dacf8dac974103156
- Loading branch information
Frida Jacobsson
committed
Nov 8, 2023
1 parent
502d474
commit 07b564f
Showing
6 changed files
with
396 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
name: CI | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
install: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: [18.x] | ||
|
||
env: | ||
CI: true | ||
NODE_OPTIONS: --max-old-space-size=4096 | ||
|
||
name: Install ${{ matrix.node-version }} | ||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1 | ||
with: | ||
egress-policy: audit | ||
|
||
- uses: actions/checkout@v4.1.1 | ||
|
||
- name: use node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3.8.2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
registry-url: https://registry.npmjs.org/ # Needed for auth | ||
|
||
- name: yarn install | ||
uses: backstage/actions/yarn-install@v0.6.5 | ||
with: | ||
cache-prefix: ${{ runner.os }}-v${{ matrix.node-version }} | ||
|
||
# The verify jobs runs all the verification that doesn't require a | ||
# diff towards main, since it takes some time to fetch that. | ||
verify: | ||
runs-on: ubuntu-latest | ||
|
||
needs: install | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: [18.x] | ||
|
||
env: | ||
CI: true | ||
NODE_OPTIONS: --max-old-space-size=4096 | ||
|
||
name: Verify ${{ matrix.node-version }} | ||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1 | ||
with: | ||
egress-policy: audit | ||
|
||
- uses: actions/checkout@v4.1.1 | ||
|
||
- name: use node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3.8.2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
registry-url: https://registry.npmjs.org/ # Needed for auth | ||
|
||
- name: yarn install | ||
uses: backstage/actions/yarn-install@v0.6.5 | ||
with: | ||
cache-prefix: ${{ runner.os }}-v${{ matrix.node-version }} | ||
|
||
- name: check for missing repo fixes | ||
run: yarn fix --check | ||
|
||
- name: validate config | ||
run: yarn backstage-cli config:check --lax | ||
|
||
- name: type checking and declarations | ||
run: yarn tsc:full | ||
|
||
- name: prettier | ||
run: yarn prettier:check | ||
|
||
- name: build all packages | ||
run: yarn backstage-cli repo build --all | ||
|
||
- name: ensure clean working directory | ||
run: | | ||
if files=$(git ls-files --exclude-standard --others --modified) && [[ -z "$files" ]]; then | ||
exit 0 | ||
else | ||
echo "" | ||
echo "Working directory has been modified:" | ||
echo "" | ||
git status --short | ||
echo "" | ||
exit 1 | ||
fi | ||
# The test job runs all tests as well as any verification step that | ||
# requires a diff towards main. | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
needs: install | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: [18.x] | ||
|
||
name: Test ${{ matrix.node-version }} | ||
services: | ||
postgres13: | ||
image: postgres:13 | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432/tcp | ||
postgres9: | ||
image: postgres:9 | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432/tcp | ||
mysql8: | ||
image: mysql:8 | ||
env: | ||
MYSQL_ROOT_PASSWORD: root | ||
options: >- | ||
--health-cmd "mysqladmin ping -h localhost" | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 3306/tcp | ||
|
||
env: | ||
CI: true | ||
NODE_OPTIONS: --max-old-space-size=4096 | ||
INTEGRATION_TEST_GITHUB_TOKEN: ${{ secrets.INTEGRATION_TEST_GITHUB_TOKEN }} | ||
INTEGRATION_TEST_GITLAB_TOKEN: ${{ secrets.INTEGRATION_TEST_GITLAB_TOKEN }} | ||
INTEGRATION_TEST_BITBUCKET_TOKEN: ${{ secrets.INTEGRATION_TEST_BITBUCKET_TOKEN }} | ||
INTEGRATION_TEST_AZURE_TOKEN: ${{ secrets.INTEGRATION_TEST_AZURE_TOKEN }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4.1.1 | ||
- name: fetch branch main | ||
run: git fetch origin main | ||
|
||
- name: use node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3.8.2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
registry-url: https://registry.npmjs.org/ # Needed for auth | ||
|
||
- name: yarn install | ||
uses: backstage/actions/yarn-install@v0.6.5 | ||
with: | ||
cache-prefix: ${{ runner.os }}-v${{ matrix.node-version }} | ||
|
||
- name: lint changed packages | ||
run: yarn backstage-cli repo lint --since origin/main | ||
|
||
- name: test changed packages | ||
run: yarn backstage-cli repo test --maxWorkers=2 --workerIdleMemoryLimit=1300M --since origin/main | ||
env: | ||
BACKSTAGE_TEST_DISABLE_DOCKER: 1 | ||
BACKSTAGE_TEST_DATABASE_POSTGRES13_CONNECTION_STRING: postgresql://postgres:postgres@localhost:${{ job.services.postgres13.ports[5432] }} | ||
BACKSTAGE_TEST_DATABASE_POSTGRES9_CONNECTION_STRING: postgresql://postgres:postgres@localhost:${{ job.services.postgres9.ports[5432] }} | ||
BACKSTAGE_TEST_DATABASE_MYSQL8_CONNECTION_STRING: mysql://root:root@localhost:${{ job.services.mysql8.ports[3306] }}/ignored | ||
|
||
- name: ensure clean working directory | ||
run: | | ||
if files=$(git ls-files --exclude-standard --others --modified) && [[ -z "$files" ]]; then | ||
exit 0 | ||
else | ||
echo "" | ||
echo "Working directory has been modified:" | ||
echo "" | ||
git status --short | ||
echo "" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env node | ||
/* | ||
* Copyright 2020 The Backstage 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. | ||
*/ | ||
|
||
const path = require('path'); | ||
|
||
// Figure out whether we're running inside the backstage repo or as an installed dependency | ||
/* eslint-disable-next-line no-restricted-syntax */ | ||
const isLocal = require('fs').existsSync(path.resolve(__dirname, '../src')); | ||
|
||
if (!isLocal || process.env.BACKSTAGE_E2E_CLI_TEST) { | ||
require('..'); | ||
} else { | ||
require('ts-node').register({ | ||
transpileOnly: true, | ||
/* eslint-disable-next-line no-restricted-syntax */ | ||
project: path.resolve(__dirname, '../../../tsconfig.json'), | ||
compilerOptions: { | ||
module: 'CommonJS', | ||
}, | ||
}); | ||
|
||
require('../src'); | ||
} |
Oops, something went wrong.