-
Notifications
You must be signed in to change notification settings - Fork 1
114 lines (106 loc) · 3.67 KB
/
ruby-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
name: Ruby CI
on:
workflow_call:
inputs:
run:
description: "The command to run (e.g. bundle exec rake)"
default: "bundle exec rake"
required: false
type: string
ruby-version:
description: "The Ruby ruby-version to use"
default: ".ruby-version"
required: false
type: string
# https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-rubygems-registry
pkg-github-com-user:
description: "GitHub username for rubygems.pkg.github.com auth"
default: "machine-user-84"
required: false
type: string
postgres:
description: "Start PostgreSQL in the GitHub Actions VM"
default: false
required: false
type: boolean
postgres-env-key:
description: "Name of the environment variable with the Postgres URL"
default: "ELEPHANTSQL_URL"
required: false
type: string
ruby-lint:
description: "Run RuboCop using https://github.com/reviewdog/action-rubocop"
default: false
required: false
type: boolean
bundle-frozen:
description: "Value to use for BUNDLE_FROZEN environment variable"
default: true
required: false
type: boolean
bundler-cache:
description: "Value to use for the setup-ruby input 'bundler-cache'"
default: true
required: false
type: boolean
cache-version:
description: "Value to use for the setup-ruby input 'cache-version'"
default: "0"
required: false
type: string
secrets:
github-token:
description: "GitHub token for private repo dependencies"
required: false
repo-github-token:
description: "The repo scoped token generated by GitHub Actions"
required: false
pkg-github-com:
description: "Value to use for BUNDLE_RUBYGEMS__PKG__GITHUB__COM"
required: false
jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Start PostgreSQL if requested
if: inputs.postgres
uses: 84codes/postgres@main
with:
env-key: ${{ inputs.postgres-env-key }}
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
env:
BUNDLE_FROZEN: ${{ inputs.bundle-frozen }}
BUNDLE_GITHUB__COM: x-access-token:${{ secrets.github-token }}
BUNDLE_RUBYGEMS__PKG__GITHUB__COM: ${{ inputs.pkg-github-com-user }}:${{ secrets.pkg-github-com }}
with:
ruby-version: ${{ inputs.ruby-version }}
bundler-cache: ${{ inputs.bundler-cache }}
cache-version: ${{ inputs.cache-version }}
- run: ${{ inputs.run }}
lint:
if: inputs.ruby-lint
runs-on: ubuntu-latest
steps:
- name: Checkout project code
uses: actions/checkout@v4
- name: Checkout lint rules
uses: actions/checkout@v4
with:
repository: 84codes/tools
token: ${{ secrets.github-token }}
path: tools
# only checkout the lint rules
sparse-checkout: |
.rubocop.yml
sparse-checkout-cone-mode: false
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ inputs.ruby-version }}
- uses: reviewdog/action-rubocop@v2
with:
github_token: ${{ secrets.repo-github-token }}
level: warning
reporter: ${{ github.event_name == 'pull_request' && 'github-pr-check' || 'github-check' }}
rubocop_extensions: rubocop-gitlab-security rubocop-performance rubocop-minitest rubocop-eightyfourcodes rubocop-rake rubocop-sequel
rubocop_flags: -c tools/.rubocop.yml -DEPS