-
Notifications
You must be signed in to change notification settings - Fork 1
105 lines (95 loc) · 3.22 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
name: Ruby CI
on:
workflow_call:
inputs:
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
reviewdog:
description: "Enable code coverage check with https://github.com/reviewdog/action-setup"
default: false
required: false
type: boolean
ruby-lint:
description: "Run RuboCop using https://github.com/reviewdog/action-rubocop"
default: false
required: false
type: boolean
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@v3
- uses: ruby/setup-ruby@v1
env:
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: true
- run: bundle exec rake test
- name: Setup reviewdog
if: inputs.reviewdog
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest
- name: Check code coverage with reviewdog
if: inputs.reviewdog
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.repo-github-token }}
run: |
git fetch
reviewdog -reporter=github-pr-review -runners=undercover
lint:
if: inputs.ruby-lint
runs-on: ubuntu-latest
steps:
- name: Checkout project code
uses: actions/checkout@v3
- name: Checkout lint rules
uses: actions/checkout@v3
with:
repository: 84codes/tools
token: ${{ secrets.github-token }}
path: tools
- uses: ruby/setup-ruby@v1
- uses: reviewdog/action-rubocop@v1
with:
github_token: ${{ secrets.repo-github-token }}
level: warning
reporter: github-pr-review
rubocop_extensions: rubocop-gitlab-security rubocop-performance rubocop-minitest rubocop-eightyfourcodes rubocop-rake
rubocop_flags: -c tools/.rubocop.yml -DEPS