-
Notifications
You must be signed in to change notification settings - Fork 1
149 lines (145 loc) · 5.13 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
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
name: Continuous integration
on:
push:
branches:
- main
pull_request: {}
jobs:
graphql-codegen-tsc:
name: graphql-codegen-tsc
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install node
uses: actions/setup-node@v4
with:
cache: yarn
- name: yarn install
run: yarn install
- name: graphql-codegen
run: yarn run graphql:codegen
- name: tsc on resulting generated files
run: yarn run tsc --noEmit
minitest:
name: minitest
runs-on: ubuntu-latest
env:
DATABASE_URL: postgres://postgres:postgres@localhost/larp_library_test
RAILS_ENV: test
services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Upgrade postgres client utilities
run: |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
sudo apt-get update
sudo apt-get install postgresql-client -y
- name: Database setup
run: bundle exec rails db:create db:migrate
- name: Run tests
run: TERM=xterm-color bundle exec rails test
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: always() # always run even if the previous step fails
with:
check_name: 'Minitest Report'
report_paths: 'test/reports/TEST-*.xml'
- name: Archive HTML test reports
uses: actions/upload-artifact@v4
if: always()
with:
name: test-reports
path: test/html_reports
docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up webpack cache
uses: actions/cache@v4
id: webpack-cache # use this to check for `cache-hit` (`steps.webpack-cache.outputs.cache-hit != 'true'`)
with:
path: build-cache
key: ${{ runner.os }}-dockerimage-webpack-${{ github.ref }}
restore-keys: |
${{ runner.os }}-dockerimage-webpack-${{ github.ref }}-
${{ runner.os }}-dockerimage-webpack-
- name: install node
uses: actions/setup-node@v4
with:
cache: yarn
- name: yarn install
run: yarn install
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build webpack bundle
run: yarn run build
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Read .ruby-version
id: ruby-version
run: echo "ruby-version=$(cat .ruby-version)" >> $GITHUB_OUTPUT
- name: Read .node-version
id: node-version
run: echo "node-version=$(cat .node-version)" >> $GITHUB_OUTPUT
- name: Build (and push to Docker Hub, if on main)
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' }}
platforms: linux/amd64
target: production
tags: |
ghcr.io/neinteractiveliterature/larp_library:${{ github.sha }}
build-args: |
RUBY_VERSION=${{ steps.ruby-version.outputs.ruby-version }}
NODE_VERSION=${{ steps.node-version.outputs.node-version }}
REVISION=${{ github.sha }}
cache-from: type=gha,scope=${{ github.workflow }}
cache-to: type=gha,mode=max,scope=${{ github.workflow }}
update-release-draft:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.event.ref == 'refs/heads/main'
needs:
- graphql-codegen-tsc
- minitest
- docker-build
outputs:
name: ${{ steps.release-drafter.outputs.name }}
html_url: ${{ steps.release-drafter.outputs.html_url }}
steps:
- uses: release-drafter/release-drafter@v6
id: release-drafter
with:
config-name: release-drafter.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Post about drafted release to Slack
id: slack
uses: slackapi/slack-github-action@v1.26.0
with:
channel-id: ${{ secrets.SlackCISuccessNotificationChannelID }}
slack-message: |
Draft Larp Library release ${{ steps.release-drafter.outputs.name }} updated:
- ${{ join(github.event.commits.*.message, '%0A- ') }}
To release Larp Library to production, visit: ${{ steps.release-drafter.outputs.html_url }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SlackToken }}