Skip to content

Commit

Permalink
Uni pr (#17308)
Browse files Browse the repository at this point in the history
* feat: cd test app

* fix: rename app

* fix: name

* fix: added dummy queries and codegen target

* fix: eslint

* fix: style

* fix: import query

* fix: import shared type

* fix: affect shared/types

* fix: add docker-next target

* fix: nx project and infra

* chore: eslint

* chore: eslint

* chore: remove jsx-a11y

* fix: ignore css

* chore: nx format:write update dirty files

* Chore: adding unicorn to uber chart

* fix: support values file per service

* fix: cleanup

* fix: added values per service

* fix: only a single service please

* fix: set service toplevel

* fix: format

* fix: use yaml not js-yaml

* fix: remove release-tag arg

* fix: console message

* chore: remove helm values refactor

* chore: remove helm values

* chore: yarn charts

* chore: charts update dirty files

* chore: nx format:write update dirty files

* chore: charts update dirty files

* fix: make unaffected

* Unicorn pipe (#17094)

* chore: Adding pipeline for unicorns

* unicorn pipe

* unicorn pipe

* unicorn pipe

* unicorn pipe

* pipetest

* pipetest

* pipetest

* chore: nx format:write update dirty files

* Update .github/workflows/unicorns.yml

Co-authored-by: Jón Levy <[email protected]>

* suggestions

* chore: nx format:write update dirty files

* unicorn pipe

* suggestions

---------

Co-authored-by: andes-it <[email protected]>
Co-authored-by: Jón Levy <[email protected]>

* chore: charts update dirty files

* chore: Adding pipeline to detect unicorns (#17165)

* chore: Adding tests if pipeline should run on unicorns

* chore: nx format:write update dirty files

* chore: find release branch

* chore: find release branch

* chore: find release branch

* chore: find release branch

* chore: find release branch

* chore: find release branch

* chore: find release branch

* chore: find release branch

* chore: find release branch

* chore: find release branch

* chore: find release branch

* chore: find release branch

* chore: find release branch

* chore: find release branch

* chore: find release branch

* chore: find release branch

* chore: nx format:write update dirty files

* chore: find release branch

* chore: find release branch

* cleanup

* branch sync

* mergequeue

* chore: testing pipeline

* chore: nx format:write update dirty files

* ignore

* ignore

* ignore

* testing pipeline

* testing pipeline

* testing pipeline

---------

Co-authored-by: andes-it <[email protected]>

* chore: nx format:write update dirty files

* chore: testing mergequeue

* Adding mergequeue ci

* chore: testing mergequeue

* chore: testing mergequeue

* Uni pr (#17280)

* chore: testing mergequeue

* Adding mergequeue ci

* chore: testing mergequeue

* chore: testing mergequeue

* chore: testing mergequeue

* chore: testing mergequeue

* chore: nx format:write update dirty files

* chore: nx format:write update dirty files

* chore: testing mergequeue

* chore: testing mergequeue

* Uni pr (#17280)

* chore: testing mergequeue

* Adding mergequeue ci

* chore: testing mergequeue

* chore: testing mergequeue

* chore: testing mergequeue

---------

Co-authored-by: Jón Levy <[email protected]>
Co-authored-by: andes-it <[email protected]>
  • Loading branch information
3 people authored Dec 20, 2024
1 parent e146770 commit 19553a3
Show file tree
Hide file tree
Showing 42 changed files with 1,458 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/config-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ on:
- 'main'
- 'release/**'
- 'pre-release/**'
- '!unicorn-pipe-rel3'
- '!feature/unicorn-app'
paths:
- 'charts/**'
- 'infra/**'
- '**/infra/**'
workflow_dispatch: {}
pull_request:
branches:
- '!uni-pr'
- '!feature/unicorn-app'
paths:
- 'charts/**'
- 'infra/**'
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/external-checks.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: External checks

on:
pull_request: {}
pull_request:
branches-ignore:
- 'feature/unicorn-app'
workflow_dispatch: {}

defaults:
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/merge-queue-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Validate code in the merge queue

on:
merge_group:

jobs:
validate-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Display info
run: |
echo "Hallo Merge Queue"
pwd
tree -a -I '.git'
git status
- name: Run slow CI (emulated by a long sleep)
run: sleep 300
3 changes: 3 additions & 0 deletions .github/workflows/pullrequest-close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
pull_request:
types:
- closed
branches-ignore:
- 'uni-pr'
- 'feature/unicorn-app'

defaults:
run:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pullrequest-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- reopened
- edited
- synchronize
branches-ignore:
- 'uni-pr'
- 'feature/unicorn-app'

defaults:
run:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Monorepo pipeline - pull request

on:
pull_request: {}
pull_request:
branches-ignore:
- 'uni-pr'
- 'feature/unicorn-app'
workflow_dispatch: {}

defaults:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ on:
- 'main'
- 'release/**'
- 'pre-release/**'
- '!uni-pr'
- '!feature/unicorn-app'
paths-ignore:
- '**/*.md'
tags:
- docker-build-*
workflow_dispatch:
create:
pull_request:
branches:
- '!uni-pr'
- '!feature/unicorn-app'
types:
- opened
- synchronize
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/revert-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ on:
- completed
branches:
- main
- '!uni-pr'
- '!feature/unicorn-app'
pull_request:
branches:
- '!uni-pr'
types:
- opened
- synchronize
Expand Down
106 changes: 106 additions & 0 deletions .github/workflows/unicorns.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Unicorn CI/CD pipeline
on:
workflow_dispatch:
create:
pull_request:
types:
- opened
- synchronize
- labeled
- closed
pull_request_review:
types: [submitted]
concurrency:
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-a-fallback-value
group: push-unicorn${{ github.head_ref || github.run_id }}
cancel-in-progress: true

defaults:
run:
shell: bash
jobs:
printJob:
name: Print event
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
check-approved:
name: Is PR approved
runs-on: ubuntu-latest
outputs:
IS_APPROVED: ${{ steps.check-approved.outputs.result }}
steps:
- name: Check if PR is approved
id: check-approved
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
if (!context || !context.payload || !context.payload.pull_request) {
return false;
}
var reviews = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
if(!reviews || !reviews.data == null) {
return false;
}
var declined = reviews.data.filter(review => review.state != 'APPROVED').length > 0;
var pending = context.payload.pull_request.requested_teams.length > 0
console.log(!(declined && pending) ? 'Pr is approved' : 'Pr is not approved');
return !(declined && pending);
- name: output
run: echo "IS_APPROVED=${{ steps.check-approved.outputs.result }}" >> $GITHUB_OUTPUT

check-unicorn:
name: Is this a unicorn PR
needs: check-approved
if: ${{ needs.check-approved.outputs.IS_APPROVED }}"
runs-on: ec2-runners
container:
image: public.ecr.aws/m3u4c4h9/island-is/actions-runner-public:latest
timeout-minutes: 10
steps:
- run: echo "selected runner = ${{ runner.name }}"
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version-file: 'package.json'

- name: Setup yarn
run: corepack enable

- name: Get cache
id: get-cache
uses: ./.github/actions/get-cache
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
enable-cache: 'node_modules,generated-files'

- name: Check unicorn affected
id: unicorn-affected
env:
BaseRef: ${{ github.base_ref }} #The target branch e.g. main (feature/unicorn-app)
HeadRef: ${{ github.head_ref }} #The branch being merged e.g. (unicorn-pipe-rel3)
run: |
echo "Comparing nx affected for $HeadRef using origin/$BaseRef as base branch"
echo IS_UNICORN=$(node scripts/ci/unicorn-utils.mjs "{\"baseBranch\": \"origin/$BaseRef\", \"mergeBranch\": \"$HeadRef\" }") >> "$GITHUB_OUTPUT"
- name: Results
run: |
echo "Unicorn = ${{ steps.unicorn-affected.outputs.IS_UNICORN }}"
- name: Find Latest Release Branch
run: |
node scripts/ci/get-last-release.mjs $(git branch -r)
- run: "echo 'latest release: ${{ steps.get_latest_release.outputs.data }}'"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ TODO
.env
.env.*
.envrc.private
nx-cloud.env
.nvmrc
.node-version
# IDE - VSCode
Expand Down
55 changes: 55 additions & 0 deletions apps/unicorn-app/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"extends": ["plugin:@nx/react", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allowCircularSelfDependency": true,
"allow": ["../../../infra/src/dsl"],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
],
"simple-import-sort/imports": [
"warn",
{
"groups": [
// React related packages come first, followed by all external imports.
["^react", "^\\w", "^@(?!island).+"],
// Then island.is packages.
["^(@island.is).*"],
// Then all other imports in this order: "../", "./", "./css"
[
"^\\.\\.(?!/?$)",
"^\\.\\./?$",
"^\\./(?=.*/)(?!/?$)",
"^\\.(?!/?$)",
"^\\./?$",
"^.+\\.?(css)$"
]
]
}
]
},
"plugins": ["simple-import-sort"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
24 changes: 24 additions & 0 deletions apps/unicorn-app/codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
schema:
- apps/api/src/api.graphql
documents: apps/unicorn-app/src/queries/*.{ts,tsx}
generates:
apps/web/graphql/schema.ts:
plugins:
- typescript
- typescript-operations
config:
exportFragmentSpreadSubTypes: true
scalars:
DateTime: Date
JSON: '{ [key: string]: any }'
namingConvention:
typeNames: change-case#pascalCase
apps/web/graphql/fragmentTypes.json:
plugins:
- fragment-matcher
config:
module: commonjs
apolloClientVersion: 3
hooks:
afterAllFileWrite:
- prettier --write
6 changes: 6 additions & 0 deletions apps/unicorn-app/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
declare module '*.svg' {
const content: any
export const ReactComponent: any
export default content
}
34 changes: 34 additions & 0 deletions apps/unicorn-app/infra/infra.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { service, ServiceBuilder } from '../../../infra/src/dsl/dsl'
const serviceName = 'unicorn-app'
export const serviceSetup = (): ServiceBuilder<typeof serviceName> =>
service(serviceName)
.image(serviceName)
.namespace(serviceName)
.serviceAccount(serviceName)
.ingress({
primary: {
host: {
dev: serviceName,
staging: serviceName,
prod: serviceName,
},
paths: ['/'],
},
})
.replicaCount({
default: 1,
min: 1,
max: 10,
})
.resources({
limits: {
cpu: '200m',
memory: '256Mi',
},
requests: {
cpu: '50m',
memory: '128Mi',
},
})
.liveness('/liveness')
.readiness('/readiness')
11 changes: 11 additions & 0 deletions apps/unicorn-app/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'unicorn-app',
preset: '../../jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/next/babel'] }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/apps/unicorn-app',
}
5 changes: 5 additions & 0 deletions apps/unicorn-app/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
22 changes: 22 additions & 0 deletions apps/unicorn-app/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//@ts-check

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { composePlugins, withNx } = require('@nx/next')

/**
* @type {import('@nx/next/plugins/with-nx').WithNxOptions}
**/
const nextConfig = {
nx: {
// Set this to true if you would like to use SVGR
// See: https://github.com/gregberge/svgr
svgr: false,
},
}

const plugins = [
// Add more Next.js plugins to this list if needed.
withNx,
]

module.exports = composePlugins(...plugins)(nextConfig)
Loading

0 comments on commit 19553a3

Please sign in to comment.