-
Notifications
You must be signed in to change notification settings - Fork 47
119 lines (104 loc) · 3.74 KB
/
_run_tests.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
# This workflow runs the main test suite.
#
# This workflow is pimarily meant to be called by other workflows, but it can be run manually.
name: "🧪 ~ Run gem tests"
on:
workflow_call:
workflow_dispatch:
jobs:
calculate_matrix:
name: 💎 Generate Gem List
runs-on: ubuntu-latest
outputs:
gems: ${{ steps.generate-gem-list.outputs.result }}
steps:
- name: Checkout Core Repo
uses: "actions/checkout@v4"
with:
path: tmp/starter/local/bullet_train-core
- uses: actions/github-script@v7
id: generate-gem-list
name: Generate Gem List
with:
script: |
const globber = await glob.create('tmp/starter/local/bullet_train-core/*/*.gemspec')
const gems = []
for await (const file of globber.globGenerator()) {
console.log(file)
var fileParts = file.split("/")
var gemspecFileName = fileParts[fileParts.length];
var gemname = fileParts[fileParts.length - 2];
console.log("gemname =", gemname)
gems.push(gemname)
}
return gems
test:
runs-on: ubuntu-latest
needs: calculate_matrix
strategy:
fail-fast: false
matrix:
gem: ${{ fromJson(needs.calculate_matrix.outputs.gems) }}
name: ${{ format('{0}', matrix.gem) }}
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 2s
--health-timeout 2s
--health-retries 5
ports:
- 5432:5432
env:
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: postgres
RAILS_ENV: test
CI: 1
defaults:
run:
working-directory: tmp/starter/local/bullet_train-core/${{ matrix.gem }}
steps:
- name: Checkout Core Repo
uses: "actions/checkout@v4"
with:
path: tmp/starter/local/bullet_train-core
- name: Copy .ruby-version
run: cp ../.ruby-version ./
- uses: "ruby/setup-ruby@v1"
with:
rubygems: latest
bundler: latest
bundler-cache: true
working-directory: tmp/starter/local/bullet_train-core/${{ matrix.gem }} # setup-ruby does't pick up the job default.
# TODO: Sometimes the step above complains about the lockfile being fronzen.
# When that happens you can get things moving again by changing the bundler-cache
# option above to false. Then you _must_ uncomment the line for `bundle install` and
# you can also uncomment the following lines to find out what changed unexpectedly.
# I _think_ I've got things set up so that this shouldn't be an issue any more, but
# I'm leaving this stuff here in case it comes in handy in the near future.
#
#- run: bundle install
#- run: cat Gemfile.lock
#- run: git diff Gemfile.lock
- run: bin/rails db:setup
if: ${{ hashFiles(format('tmp/starter/local/bullet_train-core/{0}/test/dummy/db/schema.rb', matrix.gem)) != '' }}
- name: Run Tests
run: bin/rails test
- name: Upload Test Coverage Data
uses: actions/upload-artifact@v4
if: always()
with:
name: test_coverage_${{ matrix.gem }}.log
path: tmp/starter/local/bullet_train-core/${{ matrix.gem }}/coverage/.resultset.json
include-hidden-files: true
- name: Upload Test Summary Logs
uses: actions/upload-artifact@v4
if: always()
with:
name: test_summary_${{ matrix.gem }}.log
path: ${{ format('tmp/starter/local/bullet_train-core/{0}/test/reports/**/TEST-*.xml', matrix.gem) }}