Skip to content
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
31 changes: 31 additions & 0 deletions .github/workflows/auto-delete-merged-branches.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Automatically delete merged branches on PR merge

on:
pull_request:
types:
- closed

permissions:
contents: write
pull-requests: write

jobs:
delete-merged-branches:
runs-on: ubuntu-latest

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

- name: Delete Branch after merge (Except main)
run: |
BRANCH_NAME=${{ github.event.pull_request.head.ref }}

# Prevent deletion of the main branch
if [ "${{ github.event.pull_request.merged }}" == "true" ] && [ "$BRANCH_NAME" != "main" ]; then
echo "Deleting merged branch: $BRANCH_NAME"
git push origin --delete $BRANCH_NAME
else
echo "Branch not deleted. Either it was not merged or it was 'main'."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/cd-workflow.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

name: Deploy backstage
on:
workflow_dispatch:
push:
branches:
- main
workflow_run:
workflows: ["CI Workflow"]
types:
- completed

jobs:
create-and-push-image:
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/ci-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,30 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['20.x', '22.x']
node-version: ['20.x']

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Enable Corepack
run: corepack enable

- name: Set Yarn Version
run: corepack prepare [email protected] --activate

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
cache: 'yarn'

- name: Check Node.js version
run: node -v

- name: Install dependencies
run: yarn install --frozen-lockfile
run: yarn install

# - name: Lint code
# run: yarn lint:all
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/delete-old-branches.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Delete old merged and unmerged branches

on:
schedule:
- cron: '0 0 * * *' #Run every day at midnight
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
delete-old-branches:
runs-on: ubuntu-latest

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

- name: Delete old branches (Except main)
run: |
git fetch --prune

# Delete merged branches older than 30 days, except main
for branch in $(git branch -r --merged | grep -v "main" | grep -v "HEAD"); do
BRANCH_NAME=$(echo $branch | sed 's/origin\///')
LAST_COMMIT_DATE=$(git log -1 --format=%ci $BRANCH_NAME)
DAYS_OLD=$(echo $(( ( $(date +%s) - $(date -d "$LAST_COMMIT_DATE" +%s) ) / 86400 )))

if [[ $DAYS_OLD -gt 30 ]]; then
echo "Deleting merged branch: $BRANCH_NAME"
git push origin --delete $BRANCH_NAME
fi
done

# Delete unmerged branches older than 90 days, except main
for branch in $(git branch -r --no-merged | grep -v "main" | grep -v "HEAD"); do
BRANCH_NAME=$(echo $branch | sed 's/origin\///')
LAST_COMMIT_DATE=$(git log -1 --format=%ci $BRANCH_NAME)
DAYS_OLD=$(echo $(( ( $(date +%s) - $(date -d "$LAST_COMMIT_DATE" +%s) ) / 86400 )))

if [[ $DAYS_OLD -gt 90 ]]; then
echo "Deleting stale unmerged branch: $BRANCH_NAME"
git push origin --delete $BRANCH_NAME
fi
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 16 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,33 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Enable Corepack
run: corepack enable

- name: Set Yarn Version
run: corepack prepare [email protected] --activate


- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- run: yarn install
- run: yarn backstage-cli repo test

run-e2e-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Enable Corepack
run: corepack enable

- name: Set Yarn Version
run: corepack prepare [email protected] --activate

- name: Use Node.js
uses: actions/setup-node@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ COPY --chown=node:node examples ./examples


# This switches many Node.js dependencies to production mode. Important APP_ENV and NODE_ENV serve two different purposes
ENV NODE_ENV production
ENV NODE_ENV=production

# This disables node snapshot for Node 20 to work with the Scaffolder
ENV NODE_OPTIONS="--no-node-snapshot"
Expand Down
14 changes: 14 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Config } from 'jest';

const config: Config = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
'^.+\\.(js|jsx)$': 'babel-jest',
},
transformIgnorePatterns: ['/node_modules/'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
};

export default config;
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,29 @@
]
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/preset-env": "^7.26.0",
"@babel/preset-react": "^7.26.3",
"@babel/preset-typescript": "^7.26.0",
"@backstage/cli": "^0.29.0",
"@backstage/e2e-test-utils": "^0.1.1",
"@playwright/test": "^1.32.3",
"@spotify/prettier-config": "^12.0.0",
"@testing-library/react": "^16.2.0",
"@types/babel__core": "^7",
"@types/babel__preset-env": "^7",
"babel-jest": "^29.7.0",
"canvas": "^2.11.2",
"concurrently": "^8.0.0",
"cross-env": "^7.0.3",
"jest": "^29.7.0",
"jest-canvas-mock": "^2.5.2",
"jsdom": "^24.0.0",
"lerna": "^7.3.0",
"node-gyp": "^10.0.1",
"prettier": "^2.3.2",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"typescript": "~5.2.0"
},
"resolutions": {
Expand Down
29 changes: 29 additions & 0 deletions packages/app/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { render, waitFor } from '@testing-library/react';
import App from './App';

describe('App', () => {
it('should render', async () => {
process.env = {
NODE_ENV: 'test',
APP_CONFIG: [
{
data: {
app: { title: 'Test' },
backend: { baseUrl: 'http://localhost:7007' },
techdocs: {
storageUrl: 'http://localhost:7007/api/techdocs/static/docs',
},
},
context: 'test',
},
] as any,
};

const rendered = render(<App />);

await waitFor(() => {
expect(rendered.baseElement).toBeInTheDocument();
});
});
});
Empty file.
Loading
Loading