-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (117 loc) · 3.67 KB
/
Copy pathci-cd.yml
File metadata and controls
147 lines (117 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: CI/CD Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Generate SDK code from OpenAPI
run: npx nx codegen sdk
- name: Run linting
run: npx nx run-many -t lint
- name: Run formatting check
run: npm run format:check
- name: Run type checking
run: npx nx run-many -t typecheck
- name: Build packages
run: npx nx run-many -t build
- name: Run tests with coverage
run: npx nx run-many -t test --coverage
- name: Upload coverage to Codecov
if: matrix.node-version == '20.x'
uses: codecov/codecov-action@v3
with:
files: ./packages/sdk/coverage/lcov.info,./packages/cli/coverage/lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
- name: SonarQube Scan
if: matrix.node-version == '20.x'
uses: SonarSource/sonarqube-scan-action@v5
with:
args: |
-Dsonar.javascript.lcov.reportPaths=packages/sdk/coverage/lcov.info,packages/cli/coverage/lcov.info
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
build-docs:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Generate SDK code from OpenAPI
run: npx nx codegen sdk
- name: Build SDK package
run: npx nx build sdk
- name: Generate documentation
run: npm run docs
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
cname: aignostics-platform-sdk.github.io
release:
runs-on: ubuntu-latest
needs: [test, build-docs]
if: github.ref == 'refs/heads/main'
environment:
name: production
url: https://github.com/aignostics/typescript-sdk/releases
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
registry-url: 'https://npm.pkg.github.com'
- name: Install dependencies
run: npm ci
- name: Generate SDK code from OpenAPI
run: npx nx codegen sdk
- name: Build all packages
run: npx nx run-many -t build
- name: Release SDK
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: packages/sdk
run: npx semantic-release
- name: Release CLI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: packages/cli
run: npx semantic-release