-
Notifications
You must be signed in to change notification settings - Fork 134
115 lines (95 loc) · 2.69 KB
/
ci.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
name: CI
on:
push:
branches:
- main
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Setup npm
run: npm install
- name: Rubocop
run: bundle exec rubocop
- name: ESLint
run: npx eslint .
test:
runs-on: ubuntu-latest
name: Ruby ${{ matrix.ruby }} (redis ${{ matrix.redis }})
timeout-minutes: 10
env:
PGHOST: localhost
PGPASSWORD: postgres
PGUSER: postgres
strategy:
fail-fast: false
matrix:
ruby: ["2.6", "2.7", "3.0", "3.1"]
redis: [5, 6]
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: message_bus_test
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: ${{ format('redis:{0}', matrix.redis) }}
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Tests
env:
TESTOPTS: --verbose
run: bundle exec rake
publish:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Release gem
uses: discourse/publish-rubygems-action@v3
id: publish-gem
env:
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
GIT_EMAIL: [email protected]
GIT_NAME: discoursebot
- name: Update package version
if: steps.publish-gem.outputs.new_version == 'true'
run: |
VERSION=$(ruby -r './lib/message_bus/version' -e 'puts MessageBus::VERSION')
sed -i "s/0.0.0-version-placeholder/$VERSION/" package.json
git config --global user.email "[email protected]"
git config --global user.name "Discourse CI"
git add package.json
git commit -m 'bump'
- name: Publish package
uses: JS-DevTools/npm-publish@v3
if: steps.publish-gem.outputs.new_version == 'true'
with:
token: ${{ secrets.NPM_TOKEN }}