-
-
Notifications
You must be signed in to change notification settings - Fork 49
158 lines (147 loc) · 5.28 KB
/
ci.yml
File metadata and controls
158 lines (147 loc) · 5.28 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# This file is synced from hanakai-rb/repo-sync
name: CI
run-name: ${{ github.ref_type == 'tag' && format('Release {0}', github.ref_name) || 'CI' }}
on:
push:
branches: ["main", "release-*", "ci/*"]
tags: ["v*"]
pull_request:
branches: ["main", "release-*"]
schedule:
- cron: "30 4 * * *"
permissions:
contents: read
jobs:
tests:
name: Tests (Ruby ${{ matrix.ruby }}, Rack ${{ matrix.rack }})
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.optional || false }}
strategy:
fail-fast: false
matrix:
ruby:
- "4.0"
- "3.4"
- "3.3"
rack:
- "~> 2.0"
- "~> 3.0"
include:
- ruby: "4.0"
rack: "~> 2.0"
coverage: "true"
- ruby: "jruby"
rack: "~> 2.0"
optional: true
- ruby: "jruby"
rack: "~> 3.0"
optional: true
env:
COVERAGE: ${{ matrix.coverage }}
RACK_MATRIX_VALUE: ${{ matrix.rack || '' }}
# Env below included from ./repo-sync-extensions/ci-env.yml
POSTGRES_BASE_URL: postgres://postgres:password@localhost:5432/hanami_cli_test
# Enable ObjectSpace for tests
JRUBY_OPTS: "-X+O"
# Services included from ./repo-sync-extensions/ci-services.yml
services:
mysql:
image: mysql:9.6.0
env:
MYSQL_ROOT_PASSWORD: password
ports:
- 3307:3306
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 3
postgres:
# Use postgres:14 for CLI compatibility with ubuntu-latest, currently ubuntu-22.04
# See https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
image: postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98
with:
persist-credentials: false
- name: Install package dependencies
run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
- name: Set up Ruby
uses: ruby/setup-ruby@0cb964fd540e0a24c900370abf38a33466142735 # zizmor: ignore[cache-poisoning]
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
env:
RACK_MATRIX_VALUE: ${{ matrix.rack || '' }}
- name: Run all tests
id: test
run: |
status=0
bundle exec rake || status=$?
if [ ${status} -ne 0 ] && [ "${{ matrix.optional }}" == "true" ]; then
echo "::warning::Optional matrix job failed."
echo "optional_fail=true" >> "${GITHUB_OUTPUT}"
echo "optional_fail_status=${status}" >> "${GITHUB_OUTPUT}"
exit 0 # Ignore error here to keep the green checkmark
fi
exit ${status}
env:
RACK_MATRIX_VALUE: ${{ matrix.rack || '' }}
- name: Create optional failure comment
if: ${{ matrix.optional && github.event.pull_request }}
uses: hanakai-rb/repo-sync/pr-comment-artifact@main
with:
name: ci-ruby-${{ matrix.ruby }}
pr-number: ${{ github.event.pull_request.number }}
comment-tag: ruby-${{ matrix.ruby }}-optional-failure
message: "ℹ️ Optional job failed: Ruby ${{ matrix.ruby }}"
mode: ${{ steps.test.outputs.optional_fail == 'true' && 'upsert' || 'delete' }}
workflow-keepalive:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: liskin/gh-workflow-keepalive@7a9194bad497f0b993708eeaf10fc0a2d726eb71
release:
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
needs: tests
steps:
- name: Trigger release workflow
uses: actions/github-script@450193c5abd4cdb17ba9f3ffcfe8f635c4bb6c2a
with:
github-token: ${{ secrets.RELEASE_MACHINE_DISPATCH_TOKEN }}
script: |
const tag = context.ref.replace("refs/tags/", "");
const repo = context.repo.owner + "/" + context.repo.repo;
const tagMessage = await github.rest.git.getTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag_sha: context.sha
}).then(res => res.data.message).catch(() => "");
const announce = /(skip-announce|no-announce)/i.test(tagMessage) ? "false" : "true";
await github.rest.actions.createWorkflowDispatch({
owner: "hanakai-rb",
repo: "release-machine",
workflow_id: "release.yml",
ref: "main",
inputs: { repo, tag, announce }
});
const workflowUrl = "https://github.com/hanakai-rb/release-machine/actions/workflows/release.yml";
await core.summary
.addHeading("Release Triggered")
.addRaw(`Triggered release workflow for <code>${tag}</code>`)
.addLink("View release workflow", workflowUrl)
.write();