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

chore: Add backstage instance for test purposes #4

Merged
merged 1 commit into from
Dec 6, 2022
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
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git
.yarn/cache
.yarn/install-state.gz
node_modules
packages/*/src
packages/*/node_modules
plugins
*.local.yaml
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ site

# Local configuration files
*.local.yaml
*.dev.yaml

# Sensitive credentials
*-credentials.yaml
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ repos:
- id: prettier
additional_dependencies:
- prettier
- "@spotify/prettier-config"
- '@spotify/prettier-config'
2 changes: 0 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ dist
dist-types
coverage
.vscode
*.yaml
*.md
14 changes: 7 additions & 7 deletions .prow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ presubmits:
containers:
- image: quay.io/thoth-station/thoth-precommit-py38:v0.12.5
command:
- "pre-commit"
- "run"
- "--all-files"
- 'pre-commit'
- 'run'
- '--all-files'
resources:
requests:
memory: "500Mi"
cpu: "300m"
memory: '500Mi'
cpu: '300m'
limits:
memory: "1Gi"
cpu: "300m"
memory: '1Gi'
cpu: '300m'
34 changes: 14 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ If you start developing a plugin that you aim to release as open source, we sugg

You can also use this process if you have an idea for a good plugin but you hope that someone else will pick up the work.

## Start a new plugin
## Create a new plugin

Run the following command to start a new plugin and follow the instructions:

Expand All @@ -26,28 +26,22 @@ yarn new
## Develop a new plugin together with a local backstage instance

If you don't already have a backstage instance repository, you can easily create one via the following command. Please do so outside of this repository.
Backstage's support for standalone plugin development is very limited (especially for backend plugins), therefore we include a minimal test instance within this repository.

```sh
npx @backstage/create-app
```
1. Install the plugin via `yarn workspace [app|backend] add @janus-idp/<PLUGIN_NAME>@*` (`@*` at the end ensures the package is always linked to the local package in the `plugins` folder)
2. Run `yarn start`

Then, please [link](https://classic.yarnpkg.com/lang/en/docs/cli/link/) the plugin package to this instance:
### Developing a frontend plugin

```sh
pushd plugins/<YOUR_PLUGIN>
yarn link
popd
pushd <YOUR_BACKSTAGE_INSTANCE>
yarn link @janus-idp/<YOUR_PLUGIN>
popd
```
In case your plugin supports standalone mode, you can use `yarn start` command in your plugin directory directly and you don't have to install the plugin as mentioned above.

### Plugin specific config file

To revert this change, please use [`yarn unlink`](https://classic.yarnpkg.com/en/docs/cli/unlink) in reverse order.
You can augment the configuration for a plugin by running `yarn start --config <CONFIG_FILE>`.

## Releasing packages

Backstage plugins in the Janus-IDP community aim for high release velocity for the time being. This allows us to rapidly prototype, develop and test plugins in the wild. Current release schedule reflects this approach, therefore a new release is triggered on each **push** to the *main* branch. Only packages which are affected by the recent changes are released.
Backstage plugins in the Janus-IDP community aim for high release velocity for the time being. This allows us to rapidly prototype, develop and test plugins in the wild. Current release schedule reflects this approach, therefore a new release is triggered on each **push** to the _main_ branch. Only packages which are affected by the recent changes are released.

### Configuration

Expand All @@ -72,10 +66,10 @@ We use [semantic-release](https://semantic-release.gitbook.io/semantic-release/)

Please read [following guidelines](https://semantic-release.gitbook.io/semantic-release/#commit-message-format) to learn, how to format your commit messages:

| Commit message | Release type |
| -------------- | ------------ |
| <pre>fix(pencil): stop graphite breaking when too much pressure applied</pre> | Fix Release (`vX.Y.⬆️` ) |
| <pre>feat(pencil): add 'graphiteWidth' option</pre> | Feature Release (`vX.⬆️.0`) |
| Commit message | Release type |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| <pre>fix(pencil): stop graphite breaking when too much pressure applied</pre> | Fix Release (`vX.Y.⬆️` ) |
| <pre>feat(pencil): add 'graphiteWidth' option</pre> | Feature Release (`vX.⬆️.0`) |
| <pre>perf(pencil): remove graphiteWidth option<br><br>BREAKING CHANGE: The graphiteWidth option has been removed.<br>The default graphite width of 10mm is always used for performance reasons.</pre> | Breaking Release (`v⬆️.0.0`) <br>(Note that the `BREAKING CHANGE:` token must be **in the footer** of the commit) |

Commit messages are used to populate a `CHANGELOG.md` file for each individual package (if the commit is relevant for that particular package folder).
Expand Down
1 change: 1 addition & 0 deletions app-config.local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Backstage override configuration for your local development environment
35 changes: 35 additions & 0 deletions app-config.production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
app:
# Should be the same as backend.baseUrl when using the `app-backend` plugin.
baseUrl: http://localhost:7007

backend:
# Note that the baseUrl should be the URL that the browser and other clients
# should use when communicating with the backend, i.e. it needs to be
# reachable not just from within the backend host, but from all of your
# callers. When its value is "http://localhost:7007", it's strictly private
# and can't be reached by others.
baseUrl: http://localhost:7007
# The listener can also be expressed as a single <host>:<port> string. In this case we bind to
# all interfaces, the most permissive setting. The right value depends on your specific deployment.
listen: ':7007'

# config options: https://node-postgres.com/api/client
database:
client: pg
connection:
host: ${POSTGRES_HOST}
port: ${POSTGRES_PORT}
user: ${POSTGRES_USER}
password: ${POSTGRES_PASSWORD}
# https://node-postgres.com/features/ssl
# you can set the sslmode configuration option via the `PGSSLMODE` environment variable
# see https://www.postgresql.org/docs/current/libpq-ssl.html Table 33.1. SSL Mode Descriptions (e.g. require)
# ssl:
# ca: # if you have a CA file and want to verify it you can uncomment this section
# $file: <file-path>/ca/server.crt

catalog:
# Overrides the default list locations from app-config.yaml as these contain example data.
# See https://backstage.io/docs/features/software-catalog/software-catalog-overview#adding-components-to-the-catalog for more details
# on how to get entities into the catalog.
locations: []
102 changes: 102 additions & 0 deletions app-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
app:
title: Scaffolded Backstage App
baseUrl: http://localhost:3000

organization:
name: My Company

backend:
# Used for enabling authentication, secret is shared by all backend plugins
# See https://backstage.io/docs/tutorials/backend-to-backend-auth for
# information on the format
# auth:
# keys:
# - secret: ${BACKEND_SECRET}
baseUrl: http://localhost:7007
listen:
port: 7007
# Uncomment the following host directive to bind to specific interfaces
# host: 127.0.0.1
csp:
connect-src: ["'self'", 'http:', 'https:']
# Content-Security-Policy directives follow the Helmet format: https://helmetjs.github.io/#reference
# Default Helmet Content-Security-Policy values can be removed by setting the key to false
cors:
origin: http://localhost:3000
methods: [GET, HEAD, PATCH, POST, PUT, DELETE]
credentials: true
# This is for local development only, it is not recommended to use this in production
# The production database configuration is stored in app-config.production.yaml
database:
client: better-sqlite3
connection: ':memory:'
cache:
store: memory
# workingDirectory: /tmp # Use this to configure a working directory for the scaffolder, defaults to the OS temp-dir

integrations:
github:
- host: github.com
# This is a Personal Access Token or PAT from GitHub. You can find out how to generate this token, and more information
# about setting up the GitHub integration here: https://backstage.io/docs/getting-started/configuration#setting-up-a-github-integration
token: ${GITHUB_TOKEN}
### Example for how to add your GitHub Enterprise instance using the API:
# - host: ghe.example.net
# apiBaseUrl: https://ghe.example.net/api/v3
# token: ${GHE_TOKEN}

proxy:
'/test':
target: 'https://example.com'
changeOrigin: true

# Reference documentation http://backstage.io/docs/features/techdocs/configuration
# Note: After experimenting with basic setup, use CI/CD to generate docs
# and an external cloud storage when deploying TechDocs for production use-case.
# https://backstage.io/docs/features/techdocs/how-to-guides#how-to-migrate-from-techdocs-basic-to-recommended-deployment-approach
techdocs:
builder: 'local' # Alternatives - 'external'
generator:
runIn: 'docker' # Alternatives - 'local'
publisher:
type: 'local' # Alternatives - 'googleGcs' or 'awsS3'. Read documentation for using alternatives.

auth:
# see https://backstage.io/docs/auth/ to learn about auth providers
providers: {}

scaffolder:
# see https://backstage.io/docs/features/software-templates/configuration for software template options

catalog:
import:
entityFilename: catalog-info.yaml
pullRequestBranchName: backstage-integration
rules:
- allow: [Component, System, API, Resource, Location]
locations:
# Local example data, file locations are relative to the backend process, typically `packages/backend`
- type: file
target: ../../examples/entities.yaml

# Local example template
- type: file
target: ../../examples/template/template.yaml
rules:
- allow: [Template]

# Local example organizational data
- type: file
target: ../../examples/org.yaml
rules:
- allow: [User, Group]

## Uncomment these lines to add more example data
# - type: url
# target: https://github.com/backstage/backstage/blob/master/packages/catalog-model/examples/all.yaml

## Uncomment these lines to add an example org
# - type: url
# target: https://github.com/backstage/backstage/blob/master/packages/catalog-model/examples/acme-corp.yaml
# rules:
# - allow: [User, Group]
3 changes: 3 additions & 0 deletions backstage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "1.8.0"
}
18 changes: 18 additions & 0 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: janus-idp-backstage-plugins
description: An example of a Backstage application.
spec:
type: website
owner: group:janus-idp
lifecycle: production
---
apiVersion: backstage.io/v1alpha1
kind: Location
metadata:
name: janus-idp-backstage-plugins
spec:
targets:
- ./plugins/**/catalog-info.yaml
- ./utils/**/catalog-info.yaml
22 changes: 14 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,37 @@
"node": "16 || 18"
},
"scripts": {
"release": "multi-semantic-release",
"tsc": "tsc",
"dev": "concurrently \"yarn start\" \"yarn start-backend\"",
"start": "yarn workspace app start",
"start-backend": "yarn workspace backend start",
"build": "backstage-cli repo build",
"tsc": "tsc",
"clean": "backstage-cli repo clean",
"test": "backstage-cli repo test --passWithNoTests --coverage",
"lint": "backstage-cli repo lint",
"prettier:check": "prettier --check .",
"new": "backstage-cli new --scope @janus-idp"
"new": "backstage-cli new --scope @janus-idp",
"release": "multi-semantic-release"
},
"workspaces": {
"packages": [
"packages/*",
"plugins/*"
]
},
"devDependencies": {
"@backstage/cli": "0.21.1",
"@spotify/prettier-config": "12.0.0",
"prettier": "2.3.2",
"typescript": "4.6.4",
"multi-semantic-release": "3.0.1",
"@semantic-release/changelog": "6.0.1",
"@semantic-release/exec": "6.0.3",
"@semantic-release/git": "10.0.1",
"@semantic-release/github": "8.0.6",
"lerna": "4.0.0"
"@spotify/prettier-config": "12.0.0",
"concurrently": "^6.0.0",
"lerna": "4.0.0",
"multi-semantic-release": "3.0.1",
"prettier": "2.3.2",
"typescript": "4.6.4",
"node-gyp": "^9.0.0"
},
"resolutions": {
"@types/react": "^17",
Expand Down
9 changes: 9 additions & 0 deletions packages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# The Packages Folder

This is where your own applications and centrally managed libraries live, each
in a separate folder of its own.

From the start there's an `app` folder (for the frontend) and a `backend` folder
(for the Node backend), but you can also add more modules in here that house
your core additions and adaptations, such as themes, common React component
libraries, utilities, and similar.
1 change: 1 addition & 0 deletions packages/app/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
6 changes: 6 additions & 0 deletions packages/app/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"baseUrl": "http://localhost:3001",
"fixturesFolder": false,
"pluginsFile": false,
"retries": 3
}
21 changes: 21 additions & 0 deletions packages/app/cypress/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"plugins": ["cypress"],
"extends": ["plugin:cypress/recommended"],
"rules": {
"jest/expect-expect": [
"error",
{
"assertFunctionNames": ["expect", "cy.contains"]
}
],
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true,
"optionalDependencies": true,
"peerDependencies": true,
"bundledDependencies": true
}
]
}
}
6 changes: 6 additions & 0 deletions packages/app/cypress/integration/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
describe('App', () => {
it('should render the catalog', () => {
cy.visit('/');
cy.contains('My Company Catalog');
});
});
Loading