-
Notifications
You must be signed in to change notification settings - Fork 1
185 lines (177 loc) · 7.18 KB
/
build_test_release.yml
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Build, Test & Release
on:
push:
branches: ['main', 'develop']
pull_request:
branches: ['main', 'develop']
jobs:
buildAndTest:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
env:
# Persistent Rita
MYSQL_DATABASE: prita
MYSQL_HOST: localhost
MYSQL_USER: root
MYSQL_PASSWORD: root
PSQL_DATABASE: postgres
PSQL_HOST: localhost
PSQL_USER: postgres
PSQL_PASSWORD: postgres
# Rita Http
PORT: 3000
LOGLEVEL: info
DB_TYPE: POSTGRES
DB_HOST: localhost
DB_PORT: 5432
DB_USERNAME: postgres
DB_PASSWORD: postgres
DB_DATABASE: postgres
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: prita
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Cache Rush
uses: actions/cache@v3
with:
path: |
common/temp/install-run
~/.rush
key: ${{ runner.os }}-${{ hashFiles('rush.json') }}
- name: Cache pnpm
uses: actions/cache@v3
with:
path: |
common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
- name: Install
run: node common/scripts/install-run-rush.js install
- name: Build and test
run: node common/scripts/install-run-rush.js build-and-test --verbose
# licenses:
# runs-on: ubuntu-latest
# if: github.event_name != 'pull_request'
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# - name: Cache Rush
# uses: actions/cache@v3
# with:
# path: |
# common/temp/install-run
# ~/.rush
# key: ${{ runner.os }}-${{ hashFiles('rush.json') }}
# - name: Cache pnpm
# uses: actions/cache@v3
# with:
# path: |
# common/temp/pnpm-store
# key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
# - name: Install dependencies
# run: node common/scripts/install-run-rush.js install
# - name: FOSSA Scan
# uses: fossas/fossa-action@main
# with:
# api-key: ${{secrets.FOSSA_API_TOKEN}}
# - name: 'Run FOSSA Test'
# uses: fossas/fossa-action@main
# with:
# api-key: ${{secrets.FOSSA_API_TOKEN}}
# run-tests: true
release:
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
needs: [buildAndTest]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
- name: Cache Rush
uses: actions/cache@v3
with:
path: |
common/temp/install-run
~/.rush
key: ${{ runner.os }}-${{ hashFiles('rush.json') }}
- name: Cache pnpm
uses: actions/cache@v3
with:
path: |
common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
- name: Setup git
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Install
run: node common/scripts/install-run-rush.js install
- name: Build
run: node common/scripts/install-run-rush.js build
- name: Bump version
run: node common/scripts/install-run-rush.js version --bump --version-policy "rita-publish"
- name: Generate documentation
run: node common/scripts/install-run-rush.js generate-documentation
- run: node common/scripts/install-run-rush.js update
- run: git add .
- name: Commit changes
run: |
git commit -a -m 'chore: bump version and generate documentation' || echo "No changes to commit"
git push --follow-tags
- name: Rebase
run: |
git branch
git checkout develop
git pull
git rebase main
git push --follow-tags
- name: Publish to NPM
run: node common/scripts/install-run-rush.js publish -p --include-all --version-policy "rita-publish" --set-access-level=public
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
buildDocker:
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
needs: [release]
uses: ./.github/workflows/docker.yml
githubPackages:
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
needs: [release]
uses: ./.github/workflows/github_packages.yml
deploy:
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
needs: [release]
uses: ./.github/workflows/deploy.yml
secrets: inherit