-
Notifications
You must be signed in to change notification settings - Fork 2
98 lines (87 loc) · 3.03 KB
/
dependent-rake.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
name: dependent-rake
on:
workflow_call:
inputs:
repos-json-file:
description: json file with array of gems to test
type: string
default: .github/workflows/dependent-repos.json
command:
description: test command for dependent gem
type: string
default: bundle exec rake
matrix_os:
description: define the operating systems on which to execute jobs
type: string
jobs:
build-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.build-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: build-matrix
run: |
wget https://raw.githubusercontent.com/metanorma/ci/main/.github/workflows/ruby-matrix.json
# remove 'middle' & 'experimental' versions
echo "$(jq 'del(.ruby[1, 2])' ruby-matrix.json)" > ruby-matrix.json
if [ -n "${{ inputs.matrix_os }}" ]; then
echo "$(jq '.os = ${{inputs.matrix_os}}' ruby-matrix.json)" > ruby-matrix.json
fi
echo "matrix=$(jq -s add ${{ inputs.repos-json-file }} ruby-matrix.json | tr '\n' ' ')" >> $GITHUB_OUTPUT
rake:
name: ${{ matrix.repo }} ${{ matrix.ruby.version }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs:
- build-matrix
concurrency:
group: '${{ matrix.repo }}-${{ matrix.os }}-${{ matrix.ruby.version }}-${{ github.head_ref || github.ref_name }}'
cancel-in-progress: true
continue-on-error: ${{ matrix.experimental || matrix.ruby.experimental }}
strategy:
max-parallel: 10
fail-fast: false
matrix: ${{ fromJson(needs.build-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/checkout@v4
with:
submodules: recursive
repository: ${{ matrix.repo }}
path: dependent
fetch-depth: 1
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby.version }}
rubygems: ${{ matrix.ruby.rubygems }}
bundler-cache: true
working-directory: dependent
- name: Replace rubygems's gem with git's one
shell: python
run: |
import fileinput
import glob
import sys
import os
gem_name = '${{ github.event.repository.name }}'
if glob.glob('*.gemspec'):
gemspec = glob.glob('*.gemspec')[0]
with fileinput.FileInput(gemspec, inplace=True) as file:
for line in file:
if gem_name not in line:
print(line, end='')
print("'{}' removed from {}".format(gem_name, gemspec))
if os.path.exists("Gemfile.lock"):
os.remove("Gemfile.lock")
print("Gemfile.lock dropped")
print("> git diff")
sys.stdout.flush()
os.system("git diff")
print("> bundle add {} --path ..".format(gem_name))
sys.stdout.flush()
os.system("bundle add {} --path ..".format(gem_name))
working-directory: dependent
- run: ${{ inputs.command }}
working-directory: dependent