Skip to content

Commit 568d0fc

Browse files
committed
dev: Added CI workflows
1 parent c14cc3d commit 568d0fc

4 files changed

Lines changed: 212 additions & 0 deletions

File tree

.github/workflows/qc.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Quality Check
2+
on:
3+
# Can be run manually
4+
workflow_dispatch:
5+
6+
# on pull request
7+
pull_request:
8+
branches-ignore:
9+
- main
10+
- dev
11+
12+
# Only one run per branch at a time
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
qc:
19+
uses: panates/github-actions/.github/workflows/node-qc.yaml@v1
20+
secrets:
21+
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Release
2+
on:
3+
# Can be run manually
4+
workflow_dispatch:
5+
inputs:
6+
skip-tests:
7+
description: Skip test
8+
type: boolean
9+
default: false
10+
11+
# on git push
12+
push:
13+
branches:
14+
- main
15+
16+
# Only one run at a time
17+
concurrency:
18+
group: ${{ github.workflow }}
19+
cancel-in-progress: false
20+
21+
jobs:
22+
test:
23+
if: >
24+
!contains(github.event.head_commit.message, 'no-release') &&
25+
(
26+
(github.event_name == 'workflow_dispatch' && github.event.inputs.skip-tests != 'true') ||
27+
(
28+
github.event_name == 'push' &&
29+
!(
30+
contains(github.event.head_commit.message, 'no-test') ||
31+
(
32+
startsWith(github.event.head_commit.message, 'Merge pull request') &&
33+
contains(github.event.head_commit.message, '/dev')
34+
)
35+
)
36+
)
37+
)
38+
uses: ./.github/workflows/test.yml
39+
secrets:
40+
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
41+
42+
43+
release_after_test:
44+
# Wait for "test" job
45+
needs: test
46+
uses: panates/github-actions/.github/workflows/node-release.yaml@v1
47+
secrets:
48+
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
49+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
50+
51+
release:
52+
if: >
53+
!contains(github.event.head_commit.message, 'no-release') &&
54+
!(
55+
(github.event_name == 'workflow_dispatch' && github.event.inputs.skip-tests != 'true') ||
56+
(
57+
github.event_name == 'push' &&
58+
!(
59+
contains(github.event.head_commit.message, 'no-test') ||
60+
(
61+
startsWith(github.event.head_commit.message, 'Merge pull request') &&
62+
contains(github.event.head_commit.message, '/dev')
63+
)
64+
)
65+
)
66+
)
67+
uses: panates/github-actions/.github/workflows/node-release.yaml@v1
68+
secrets:
69+
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
70+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Test
2+
on:
3+
# Can be called from other workflows
4+
workflow_call:
5+
secrets:
6+
PERSONAL_ACCESS_TOKEN:
7+
required: true
8+
9+
# Can be run manually
10+
workflow_dispatch:
11+
12+
# on git push
13+
push:
14+
branches:
15+
- dev
16+
paths:
17+
- 'packages/*/src/**'
18+
- 'packages/*/test/**'
19+
- 'packages/*/*.{json,js,mjs,cjs}'
20+
- 'support/test/**'
21+
- '.mocharc.cjs'
22+
- 'package.json'
23+
- 'tsconfig*.json'
24+
25+
# Only one run per branch at a time
26+
concurrency:
27+
group: ${{ github.workflow }}-${{ github.ref }}
28+
cancel-in-progress: true
29+
30+
jobs:
31+
test:
32+
if: >
33+
github.event_name == 'workflow_dispatch' ||
34+
(
35+
github.event_name == 'push' &&
36+
!(
37+
contains(github.event.head_commit.message, 'no-test') ||
38+
(
39+
startsWith(github.event.head_commit.message, 'Merge pull request') &&
40+
contains(github.event.head_commit.message, '/dev')
41+
)
42+
)
43+
)
44+
runs-on: ubuntu-latest
45+
timeout-minutes: 60
46+
47+
services:
48+
postgres:
49+
image: postgres
50+
env:
51+
POSTGRES_USER: postgres
52+
POSTGRES_HOST_AUTH_METHOD: trust
53+
ports:
54+
- 5432:5432
55+
options: >-
56+
--health-cmd pg_isready
57+
--health-interval 10s
58+
--health-timeout 5s
59+
--health-retries 5
60+
61+
rabbitmq:
62+
image: rabbitmq
63+
env:
64+
RABBITMQ_DEFAULT_USER: guest
65+
RABBITMQ_DEFAULT_PASS: guest
66+
ports:
67+
- 5672:5672
68+
69+
steps:
70+
- name: Checkout
71+
uses: actions/checkout@v5
72+
73+
- name: 'Setup Environment'
74+
uses: panates/ghac-setup-node@v1
75+
with:
76+
node-version: '20.19.2'
77+
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
78+
79+
- name: Start MongoDB
80+
uses: supercharge/mongodb-github-action@1.11.0
81+
with:
82+
mongodb-version: 8.0
83+
mongodb-replica-set: test-rs
84+
85+
- name: Configure sysctl limits
86+
run: |
87+
sudo swapoff -a
88+
sudo sysctl -w vm.swappiness=1
89+
sudo sysctl -w fs.file-max=262144
90+
sudo sysctl -w vm.max_map_count=262144
91+
92+
- name: Runs Elasticsearch
93+
uses: elastic/elastic-github-actions/elasticsearch@master
94+
with:
95+
stack-version: 9.0.0
96+
security-enabled: false
97+
98+
- name: Run Kafka KRaft Broker
99+
uses: spicyparrot/kafka-kraft-action@v1.1.3
100+
with:
101+
kafka-version: "3.7.0"
102+
kafka-topics: "feed-cat,1,feed-dog,1,email-channel-1,1,email-channel-2,1,sms-channel-1,1,sms-channel-2,1"
103+
104+
- name: Install rman
105+
run: npm install rman -g
106+
107+
- name: Run qc tests
108+
run: rman run qc
109+
110+
- name: Run unit tests
111+
run: npm run citest
112+
env:
113+
NODE_OPTIONS: "--max_old_space_size=4096"
114+
KAFKA_BROKER: localhost:9092
115+
ELASTIC_HOST: http://localhost:9200
116+
117+
- name: Send coverage to Coveralls
118+
uses: coverallsapp/github-action@v2
119+
with:
120+
github-token: ${{ secrets.GITHUB_TOKEN }}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"author": "Panates",
2020
"license": "MIT",
2121
"scripts": {
22+
"citest": "rman run lint",
2223
"prepare": "husky"
2324
}
2425
}

0 commit comments

Comments
 (0)