Skip to content

Commit

Permalink
Merge pull request #9427 from weseek/feat/155548-157742-pdf-exporter-ci
Browse files Browse the repository at this point in the history
add ci workflow for pdf-converter
  • Loading branch information
yuki-takei authored Nov 22, 2024
2 parents fb09529 + 1a9a44f commit aef5e56
Show file tree
Hide file tree
Showing 7 changed files with 434 additions and 252 deletions.
168 changes: 168 additions & 0 deletions .github/workflows/ci-pdf-converter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
name: Node CI for pdf-converter

on:
push:
branches-ignore:
- release/**
- rc/**
- support/prepare-v**
paths:
- .github/mergify.yml
- .github/workflows/ci-pdf-converter.yml
- .eslint*
- tsconfig.base.json
- turbo.json
- pnpm-lock.yaml
- package.json
- apps/pdf-converter/**
- '!apps/pdf-converter/docker/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:

ci-pdf-converter-lint:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Install dependencies
run: |
pnpm add turbo --global
pnpm install --frozen-lockfile
- name: Lint
run: |
turbo run lint --filter=@growi/pdf-converter
- name: Slack Notification
uses: weseek/ghaction-slack-notification@master
if: failure()
with:
type: ${{ job.status }}
job_name: '*Node CI for growi-pdf-converter - test (${{ matrix.node-version }})*'
channel: '#ci'
isCompactMode: true
url: ${{ secrets.SLACK_WEBHOOK_URL }}

ci-pdf-converter-launch-dev:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Install dependencies
run: |
pnpm add turbo --global
pnpm install --frozen-lockfile
- name: turbo run dev:pdf-converter:ci
working-directory: ./apps/pdf-converter
run: turbo run dev:pdf-converter:ci

- name: Slack Notification
uses: weseek/ghaction-slack-notification@master
if: failure()
with:
type: ${{ job.status }}
job_name: '*Node CI for growi-pdf-converter - launch-dev (${{ matrix.node-version }})*'
channel: '#ci'
isCompactMode: true
url: ${{ secrets.SLACK_WEBHOOK_URL }}

ci-pdf-converter-launch-prod:

if: startsWith(github.head_ref, 'mergify/merge-queue/')

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Install turbo
run: |
pnpm add turbo --global
- name: Install dependencies
run: |
pnpm install --frozen-lockfile
- name: Restore dist
uses: actions/cache/restore@v4
with:
path: |
**/.turbo
**/dist
key: dist-pdf-converter-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ github.sha }}
restore-keys: |
dist-pdf-converter-prod-${{ runner.OS }}-node${{ matrix.node-version }}-
- name: Build
working-directory: ./apps/pdf-converter
run: |
turbo run build
- name: Assembling all dependencies
run: |
rm -rf out
pnpm deploy out --prod --filter @growi/pdf-converter
rm -rf apps/pdf-converter/node_modules && mv out/node_modules apps/pdf-converter/node_modules
- name: pnpm run start:prod:ci
working-directory: ./apps/pdf-converter
run: pnpm run start:prod:ci

- name: Slack Notification
uses: weseek/ghaction-slack-notification@master
if: failure()
with:
type: ${{ job.status }}
job_name: '*Node CI for growi-pdf-converter - launch-prod (${{ matrix.node-version }})*'
channel: '#ci'
isCompactMode: true
url: ${{ secrets.SLACK_WEBHOOK_URL }}

- name: Cache dist
uses: actions/cache/save@v4
with:
path: |
**/.turbo
**/dist
key: dist-pdf-converter-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ github.sha }}
33 changes: 18 additions & 15 deletions apps/pdf-converter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,29 @@
"license": "MIT",
"private": true,
"scripts": {
"dev": "nodemon --watch \"src/**/*.ts\" --ignore \"node_modules/**/*\" --exec ts-node -r \"dotenv-flow/config\" src/index.ts",
"dev:pdf-converter:ci": "ts-node -r \"dotenv-flow/config\" src/index.ts --ci",
"dev:pdf-converter": "nodemon --watch \"src/**/*.ts\" --ignore \"node_modules/**/*\" --exec ts-node -r \"dotenv-flow/config\" src/index.ts",
"start:prod:ci": "pnpm start:prod --ci",
"start:prod": "node dist/index.js",
"lint": "pnpm eslint **/*.{js,ts}",
"gen:client-code": "tsed run generate-swagger --output ./specs && orval",
"build": "pnpm gen:client-code && tsc -p tsconfig.build.json"
},
"dependencies": {
"@godaddy/terminus": "^4.12.1",
"@tsed/cli": "^5.4.3",
"@tsed/cli-core": "^5.4.3",
"@tsed/cli-generate-swagger": "^5.4.3",
"@tsed/common": "7.83.4",
"@tsed/components-scan": "7.83.4",
"@tsed/core": "7.83.4",
"@tsed/di": "7.83.4",
"@tsed/exceptions": "7.83.4",
"@tsed/json-mapper": "7.83.4",
"@tsed/platform-express": "7.83.4",
"@tsed/schema": "7.83.4",
"@tsed/swagger": "7.83.4",
"@tsed/terminus": "7.83.4",
"@tsed/cli": "=5.4.3",
"@tsed/cli-core": "=5.4.3",
"@tsed/cli-generate-swagger": "=5.4.3",
"@tsed/common": "=7.84.1",
"@tsed/components-scan": "=7.84.1",
"@tsed/core": "=7.84.1",
"@tsed/di": "=7.84.1",
"@tsed/exceptions": "=7.84.1",
"@tsed/json-mapper": "=7.84.1",
"@tsed/platform-express": "=7.84.1",
"@tsed/schema": "=7.84.1",
"@tsed/swagger": "=7.84.1",
"@tsed/terminus": "=7.84.1",
"axios": "^0.24.0",
"express": "^4.19.2",
"puppeteer": "^23.1.1",
Expand All @@ -37,6 +40,6 @@
"@types/express": "^4.17.21",
"@types/multer": "^1.4.12",
"@types/node": "^22.5.4",
"orval": "^7.1.1"
"orval": "=7.2.0"
}
}
2 changes: 1 addition & 1 deletion apps/pdf-converter/src/client-library/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Generated by orval v7.1.1 🍺
* Generated by orval v7.2.0 🍺
* Do not edit manually.
* Api documentation
* OpenAPI spec version: 1.0.0
Expand Down
9 changes: 9 additions & 0 deletions apps/pdf-converter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@ import { PlatformExpress } from '@tsed/platform-express';

import Server from './server';

function hasProcessFlag(flag: string): boolean {
return process.argv.join('').indexOf(flag) > -1;
}

async function bootstrap() {
try {
$log.debug('Start server...');
const platform = await PlatformExpress.bootstrap(Server);

await platform.listen();
$log.debug('Server initialized');

if (hasProcessFlag('ci')) {
$log.info('"--ci" flag is detected. Exit process.');
process.exit();
}
}
catch (error) {
$log.error(error);
Expand Down
3 changes: 3 additions & 0 deletions apps/pdf-converter/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
},
"exclude": ["node_modules", "dist", "test"]
}
17 changes: 17 additions & 0 deletions apps/pdf-converter/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://turbo.build/schema.json",
"extends": ["//"],
"tasks": {
"dev:pdf-converter": {
"cache": false,
"persistent": true
},
"dev:pdf-converter:ci": {
"cache": false
},
"build": {
"outputs": ["dist/**"],
"outputLogs": "new-only"
}
}
}
Loading

0 comments on commit aef5e56

Please sign in to comment.