-
-
Notifications
You must be signed in to change notification settings - Fork 1
137 lines (134 loc) · 3.84 KB
/
cicd.yml
File metadata and controls
137 lines (134 loc) · 3.84 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
name: CI/CD
on:
push:
pull_request:
jobs:
ci-node:
name: Continuous Integration Node
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, lts/*, latest]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm test
- run: npm run lint
ci-db-linting:
name: Continuous Integration Database - Linting
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache requirements
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install requirements
if: steps.cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade pip
pip install -r db/linting/requirements.txt
- name: Analysing the SQL code
run: |
bash db/linting/lint.sh
ci-db-testing:
name: Continuous Integration Database - Testing
runs-on: ubuntu-latest
services:
postgres:
image: acprdev/postgres-ci:15.2
env:
DATABASE: test_postgres
HOST: localhost
PORT: 5432
USER: postgres
PASSWORD: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Setup Perl
id: perl
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: '5.34'
install-modules-with: cpm
- name: Cache CPAN Modules
uses: actions/cache@v4
with:
path: local
key: perl-${{ steps.perl.outputs.perl-hash }}
- name: Install pg_prove
run: |
cpm install TAP::Parser::SourceHandler::pgTAP
env:
SHELL: /bin/bash
- name: Initialize database and run tests
run: |
bash db/cli/init_db.sh
bash db/cli/apply_all_migrations.sh
bash db/cli/run_tests.sh
env:
DATABASE: test_postgres
HOST: localhost
PORT: 5432
USER: postgres
PASSWORD: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
PGPASSWORD: postgres
cd:
name: Continuous Deployment
runs-on: ubuntu-latest
needs: [ci-node,ci-db-linting,ci-db-testing]
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
id-token: write
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: npm ci
- name: Publish package to NPM
run: npm publish --provenance --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Build package to upload to GitHub releases
run: |
npm pack
mv acpr-rate-limit-postgresql-*.tgz acpr-rate-limit-postgresql.tgz
- name: Create a Github release
uses: softprops/action-gh-release@v2
with:
files: acpr-rate-limit-postgresql.tgz
body:
You can view the changelog
[here](https://github.com/express-rate-limit/express-rate-limit-postgresql/blob/master/changelog.md).