Skip to content

Commit c0682d7

Browse files
committed
Fix CI
1 parent 7898df9 commit c0682d7

File tree

2 files changed

+153
-85
lines changed

2 files changed

+153
-85
lines changed

.github/actions/setup/action.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Setup Erlang and Rebar3
2+
description: |
3+
This installs the correct Erlang/OTP and Rebar3 versions, as specified in
4+
.tool-versions. It also caches _build for faster runs.
5+
outputs:
6+
cache-hit:
7+
description: See https://github.com/actions/cache#outputs
8+
value: ${{ steps.cached-deps.outputs.cache-hit }}
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- uses: erlef/setup-beam@v1
14+
id: setup-beam
15+
with:
16+
version-file: .tool-versions
17+
version-type: strict
18+
19+
- name: Fetch dependencies from cache
20+
uses: actions/cache@v3
21+
id: cached-deps
22+
with:
23+
path: |
24+
_build
25+
!_build/*/lib/merlin
26+
key: deps-${{ github.ref_name }}-${{ env.OTP_VERSION }}-${{ hashFiles('rebar.*') }}
27+
restore-keys: |
28+
deps-master-${{ env.OTP_VERSION }}-${{ hashFiles('rebar.*') }}
29+
deps-master-${{ env.OTP_VERSION }}-
30+
env:
31+
OTP_VERSION: ${{ steps.setup-beam.outputs.otp-version }}
32+
33+
- name: Fetch workspace from cache
34+
uses: actions/cache@v3
35+
id: cached-workspace
36+
with:
37+
path: |
38+
_build/*/lib/merlin
39+
key: workspace-${{ github.ref_name }}-${{ env.OTP_VERSION }}
40+
env:
41+
OTP_VERSION: ${{ steps.setup-beam.outputs.otp-version }}
42+
43+
- name: Fetch PLT from cache
44+
uses: actions/cache@v3
45+
id: cached-plt
46+
with:
47+
path: |
48+
_build/default/*_plt
49+
key: dialyzer-${{ github.ref_name }}-${{ env.OTP_VERSION }}
50+
restore-keys: |
51+
dialyzer-master-${{ env.OTP_VERSION }}
52+
env:
53+
OTP_VERSION: ${{ steps.setup-beam.outputs.otp-version }}

.github/workflows/ci.yml

Lines changed: 100 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -2,143 +2,158 @@ name: Automatic testing
22
on: [push]
33
concurrency:
44
group: ${{ github.ref }}
5-
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
5+
cancel-in-progress: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch || 'master') }}
66
env:
7-
OTP_VERSION: "25"
8-
REBAR3_VERSION: "3.22"
97
ERL_FLAGS: "-enable-feature maybe_expr"
108

119
jobs:
12-
compile-deps:
10+
commit-message:
11+
name: Check commit messages
1312
runs-on: ubuntu-latest
13+
timeout-minutes: 1
14+
env:
15+
base_ref: ${{ github.base_ref || github.event.repository.default_branch || 'master' }}
16+
1417
steps:
1518
- uses: actions/checkout@v3
16-
- uses: erlef/setup-beam@v1
1719
with:
18-
otp-version: "${{ env.OTP_VERSION }}"
19-
rebar3-version: "${{ env.REBAR3_VERSION }}"
20-
- name: Fetch dependencies from cache
21-
uses: actions/cache@v3
22-
id: cache
20+
fetch-depth: 0
21+
22+
# The `-- .` is to avoid "ambiguous argument" errors from git
23+
- name: Find fixup commits
24+
run: |
25+
echo Please rebase your fixup commits
26+
27+
git --version
28+
git log --exit-code --extended-regexp \
29+
--grep "^(fixup|squash|amend)! " \
30+
--format="::error title=Must rebase before merge::%s" \
31+
origin/${{ env.base_ref }}..${{ github.ref }} \
32+
-- .
33+
34+
- name: Find "conventional commits" style messages
35+
run: |
36+
echo Conventional Commits breaks established commit message conventions.
37+
echo Please follow these guidelines
38+
echo
39+
echo https://github.blog/2022-06-30-write-better-commits-build-better-projects/
40+
echo https://www.tpope.net
41+
42+
git --version
43+
git log --exit-code --extended-regexp --regexp-ignore-case \
44+
--grep "^[a-z]+:" \
45+
--format="::error title=Must follow commit guidelines, see step output::%s" \
46+
origin/${{ env.base_ref }}..${{ github.ref }} \
47+
-- .
48+
49+
- name: Find missing title cased messages
50+
run: |
51+
git --version
52+
! git log \
53+
--format="::error title=Must be properly capitalized::%s" \
54+
origin/${{ env.base_ref }}..${{ github.ref }} \
55+
-- . \
56+
| grep '^::.*::[a-z]'
57+
58+
compile-deps:
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v3
2362
with:
24-
path: |
25-
_build/*/*/*
26-
ebin
27-
key: deps-${{ runner.os }}-${{ env.OTP_VERSION }}-${{ env.REBAR3_VERSION }}-${{ hashFiles('rebar.*') }}
63+
fetch-depth: 0
64+
65+
- uses: ./.github/actions/setup
66+
id: setup
67+
2868
- name: Compile deps
29-
if: steps.cache.outputs.cache-hit != 'true'
69+
if: steps.setup.outputs.cache-hit != 'true'
3070
run: |
3171
rebar3 compile --deps_only
3272
rebar3 as test compile --deps_only
3373
3474
compile:
3575
needs: [compile-deps]
36-
runs-on: ubuntu-20.04
76+
runs-on: ubuntu-latest
3777
steps:
3878
- uses: actions/checkout@v3
39-
- uses: erlef/setup-beam@v1
4079
with:
41-
otp-version: "${{ env.OTP_VERSION }}"
42-
rebar3-version: "${{ env.REBAR3_VERSION }}"
43-
- name: Fetch dependencies from cache
44-
uses: actions/cache@v3
45-
id: cached-deps
46-
with:
47-
path: |
48-
_build/*/*/*
49-
ebin
50-
key: deps-${{ runner.os }}-${{ env.OTP_VERSION }}-${{ env.REBAR3_VERSION }}-${{ hashFiles('rebar.*') }}
51-
- name: Fetch workspace from cache
52-
uses: actions/cache@v3
53-
id: cached-workspace
54-
with:
55-
path: |
56-
_build/*/*/*
57-
ebin
58-
key: workspace-${{ github.ref }}
80+
fetch-depth: 0
81+
82+
- uses: ./.github/actions/setup
83+
5984
- name: Compile
6085
run: |
6186
rebar3 compile
6287
rebar3 as test compile
6388
89+
format:
90+
name: Code formatting
91+
needs: compile
92+
runs-on: ubuntu-latest
93+
timeout-minutes: 1
94+
95+
steps:
96+
- uses: actions/checkout@v3
97+
with:
98+
fetch-depth: 0
99+
100+
- uses: ./.github/actions/setup
101+
102+
- name: Run erlfmt
103+
shell: bash
104+
run: |
105+
set -o pipefail
106+
rebar3 fmt --check --verbose 2>&1 \
107+
| sed -E 's/([^:]+):([0-9]+): (.+)/::error file=\1,line=\2::\3/g'
108+
64109
ct:
65110
needs: [compile]
66-
runs-on: ubuntu-20.04
111+
runs-on: ubuntu-latest
67112
steps:
68113
- uses: actions/checkout@v3
69-
- uses: erlef/setup-beam@v1
70-
with:
71-
otp-version: "${{ env.OTP_VERSION }}"
72-
rebar3-version: "${{ env.REBAR3_VERSION }}"
73-
- name: Fetch workspace from cache
74-
uses: actions/cache@v3
75-
id: cached-workspace
76114
with:
77-
path: |
78-
_build/*/*/*
79-
ebin
80-
key: workspace-${{ github.ref }}
115+
fetch-depth: 0
116+
117+
- uses: ./.github/actions/setup
118+
81119
- name: Run CT tests
82120
run: rebar3 ct
83121

84122
eunit:
85123
needs: [compile]
86-
runs-on: ubuntu-20.04
124+
runs-on: ubuntu-latest
87125
steps:
88126
- uses: actions/checkout@v3
89-
- uses: erlef/setup-beam@v1
90127
with:
91-
otp-version: "${{ env.OTP_VERSION }}"
92-
rebar3-version: "${{ env.REBAR3_VERSION }}"
93-
- name: Fetch workspace from cache
94-
uses: actions/cache@v3
95-
id: cached-workspace
96-
with:
97-
path: |
98-
_build/*/*/*
99-
ebin
100-
key: workspace-${{ github.ref }}
128+
fetch-depth: 0
129+
130+
- uses: ./.github/actions/setup
131+
101132
- name: Run EUnit tests
102133
run: rebar3 eunit
103134

104135
dialyzer:
105136
needs: [compile]
106-
runs-on: ubuntu-20.04
137+
runs-on: ubuntu-latest
107138
steps:
108139
- uses: actions/checkout@v3
109-
- uses: erlef/setup-beam@v1
110-
with:
111-
otp-version: "${{ env.OTP_VERSION }}"
112-
rebar3-version: "${{ env.REBAR3_VERSION }}"
113-
- name: Fetch workspace from cache
114-
uses: actions/cache@v3
115-
id: cached-workspace
116140
with:
117-
path: |
118-
_build/*/*/*
119-
ebin
120-
key: workspace-dialyzer-${{ github.ref }}
121-
restore-keys:
122-
workspace-${{ github.ref }}
141+
fetch-depth: 0
142+
143+
- uses: ./.github/actions/setup
144+
123145
- name: Run Dialyzer
124146
run: rebar3 dialyzer
125147

126148
xref:
127149
needs: [compile]
128-
runs-on: ubuntu-20.04
150+
runs-on: ubuntu-latest
129151
steps:
130152
- uses: actions/checkout@v3
131-
- uses: erlef/setup-beam@v1
132-
with:
133-
otp-version: "${{ env.OTP_VERSION }}"
134-
rebar3-version: "${{ env.REBAR3_VERSION }}"
135-
- name: Fetch workspace from cache
136-
uses: actions/cache@v3
137-
id: cached-workspace
138153
with:
139-
path: |
140-
_build/*/*/*
141-
ebin
142-
key: workspace-${{ github.ref }}
154+
fetch-depth: 0
155+
156+
- uses: ./.github/actions/setup
157+
143158
- name: Run xref
144159
run: rebar3 xref

0 commit comments

Comments
 (0)