Skip to content

Commit

Permalink
Add basic ci workflow
Browse files Browse the repository at this point in the history
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
Show file tree
Hide file tree
Showing 6 changed files with 396 additions and 21 deletions.
196 changes: 196 additions & 0 deletions .github/workflows/ci.yml
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
22 changes: 11 additions & 11 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
- Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
- The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand Down Expand Up @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to Axis Backstage plugins
# Contributing to Axis Backstage plugins

Contributions are welcome, and they are greatly appreciated!
Contributions are welcome, and they are greatly appreciated!

Axis Backstage plugins are released under the Apache 2.0 License, and original creations contributed to this repo are accepted under the same license.

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"lint": "backstage-cli repo lint --since origin/master",
"lint:all": "backstage-cli repo lint",
"prettier:check": "prettier --check .",
"prettier:write": "prettier --write .",
"new": "backstage-cli new --scope internal"
},
"workspaces": {
Expand Down
37 changes: 37 additions & 0 deletions packages/cli/bin/backstage-cli
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');
}
Loading

0 comments on commit 07b564f

Please sign in to comment.