Skip to content

Commit 55e373b

Browse files
authored
CI: Extract reusable 'test' and 'build' actions (#888)
I was sitting on this idea for a while: the CI is somewhat difficult to navigate since we keep building the env anew every single time... GitHub Actions allows us to make reusable actions which we can use like subroutines for the actual workflows. Here, we have: - `run-effekt-tests` which just runs tests (we can choose whether full tests or partial ones or if it should retry) - `setup-effekt` which prepares the devenv See docs [here](https://docs.github.com/en/actions/sharing-automations/avoiding-duplication). Now it's much easier to, say, change the LLVM version in _all_ CI actions! :^) --- No idea if this works, most of this was vibe-coded with Sonnet 3.7 and I have no way of testing this locally anyways... 🤷‍♂️ 😎
1 parent 66cc819 commit 55e373b

File tree

5 files changed

+146
-118
lines changed

5 files changed

+146
-118
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: 'Run Effekt Tests'
2+
description: 'Runs Effekt tests with configurable options'
3+
4+
inputs:
5+
full-test:
6+
description: 'Whether to run full test suite'
7+
required: false
8+
default: 'true'
9+
use-retry:
10+
description: 'Whether to use retry mechanism for tests'
11+
required: false
12+
default: 'true'
13+
retry-max-attempts:
14+
description: 'Maximum number of retry attempts'
15+
required: false
16+
default: '3'
17+
retry-timeout:
18+
description: 'Timeout for retry in minutes'
19+
required: false
20+
default: '120'
21+
22+
runs:
23+
using: "composite"
24+
steps:
25+
- name: Run basic tests
26+
if: ${{ inputs.full-test != 'true' || runner.os == 'Windows' }}
27+
run: sbt "effektJVM/clean; effektJVM/testOnly effekt.JavaScriptTests -- --tests=.*examples[\\/]*pos[\\/]*sideeffects.*; effektJVM/testOnly effekt.JavaScriptTests -- --tests=.*examples[\\/]*neg[\[...]"
28+
shell: bash
29+
30+
- name: Run full test suite with retry
31+
if: ${{ inputs.full-test == 'true' && runner.os != 'Windows' && inputs.use-retry == 'true' }}
32+
uses: nick-fields/retry@v3
33+
with:
34+
timeout_minutes: ${{ inputs.retry-timeout }}
35+
max_attempts: ${{ inputs.retry-max-attempts }}
36+
retry_on: error
37+
command: EFFEKT_VALGRIND=1 EFFEKT_DEBUG=1 sbt -J-Xss1G clean test
38+
new_command_on_retry: sbt testQuick
39+
40+
- name: Run full test suite without retry
41+
if: ${{ inputs.full-test == 'true' && runner.os != 'Windows' && inputs.use-retry != 'true' }}
42+
run: EFFEKT_VALGRIND=1 EFFEKT_DEBUG=1 sbt -J-Xss1G clean test
43+
shell: bash
44+
45+
- name: Assemble fully optimized js file
46+
if: ${{ inputs.full-test == 'true' && runner.os != 'Windows' }}
47+
run: sbt effektJS/fullOptJS
48+
shell: bash
49+
50+
- name: Try installing effekt binary
51+
if: ${{ inputs.full-test == 'true' && runner.os != 'Windows' }}
52+
run: sbt install
53+
shell: bash
54+
55+
- name: Run effekt binary
56+
if: ${{ inputs.full-test == 'true' && runner.os != 'Windows' }}
57+
run: effekt.sh --help
58+
shell: bash
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: 'Setup Effekt Environment'
2+
description: 'Sets up Java, Node, SBT, and system dependencies for Effekt'
3+
4+
inputs:
5+
java-version:
6+
description: 'Java version to install'
7+
required: false
8+
default: '11'
9+
node-version:
10+
description: 'Node version to install'
11+
required: false
12+
default: '16.x'
13+
llvm-version:
14+
description: 'LLVM version to install'
15+
required: false
16+
default: '15'
17+
install-dependencies:
18+
description: 'Whether to install system dependencies (Linux only)'
19+
required: false
20+
default: 'false'
21+
install-valgrind:
22+
description: 'Whether to install valgrind (Linux only)'
23+
required: false
24+
default: 'false'
25+
26+
runs:
27+
using: "composite"
28+
steps:
29+
- name: Set up JDK ${{ inputs.java-version }}
30+
uses: actions/setup-java@v4
31+
with:
32+
java-version: ${{ inputs.java-version }}
33+
distribution: 'zulu'
34+
cache: 'sbt'
35+
36+
- name: Setup SBT
37+
uses: sbt/setup-sbt@v1
38+
39+
- name: Set up NodeJS ${{ inputs.node-version }}
40+
uses: actions/setup-node@v4
41+
with:
42+
node-version: ${{ inputs.node-version }}
43+
44+
# Only run the following on Linux-based runners
45+
- name: Update apt database
46+
if: ${{ inputs.install-dependencies == 'true' && runner.os == 'Linux' }}
47+
run: sudo apt-get update
48+
shell: bash
49+
50+
- name: Install Chez Scheme
51+
if: ${{ inputs.install-dependencies == 'true' && runner.os == 'Linux' }}
52+
run: sudo apt-get install -y chezscheme
53+
shell: bash
54+
55+
- name: Install LLVM ${{ inputs.llvm-version }}
56+
if: ${{ inputs.install-dependencies == 'true' && runner.os == 'Linux' }}
57+
run: sudo apt-get install -y llvm-${{ inputs.llvm-version }}
58+
shell: bash
59+
60+
- name: Install Valgrind
61+
if: ${{ inputs.install-valgrind == 'true' && runner.os == 'Linux' }}
62+
run: sudo apt-get install -y valgrind
63+
shell: bash
64+
65+
- name: Install libuv
66+
if: ${{ inputs.install-dependencies == 'true' && runner.os == 'Linux' }}
67+
run: sudo apt-get install -y libuv1-dev
68+
shell: bash

.github/workflows/autorelease.yml

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ on:
66
- cron: '0 3 * * 1' # Every Monday at 3am UTC
77
workflow_dispatch: # For manual triggering
88

9-
env:
10-
JAVA_VERSION: '11'
11-
NODE_VERSION: '16.x'
12-
139
jobs:
1410
check-release-needed:
1511
name: Check if release is needed
@@ -96,7 +92,7 @@ jobs:
9692
9793
echo "All checks passed. Release is needed!"
9894
99-
run-tests: # redux of usual CI defined in `ci.yml`
95+
run-tests:
10096
name: Run tests
10197
needs: [check-release-needed]
10298
runs-on: ubuntu-latest
@@ -106,32 +102,16 @@ jobs:
106102
with:
107103
submodules: 'true'
108104

109-
- name: Set up JDK ${{ env.JAVA_VERSION }}
110-
uses: actions/setup-java@v4
105+
- uses: ./.github/actions/setup-effekt
111106
with:
112-
java-version: ${{ env.JAVA_VERSION }}
113-
distribution: 'zulu'
114-
cache: 'sbt'
115-
116-
- name: Setup SBT
117-
uses: sbt/setup-sbt@v1
107+
install-dependencies: 'true'
118108

119-
- name: Set up NodeJS ${{ env.NODE_VERSION }}
120-
uses: actions/setup-node@v4
109+
- uses: ./.github/actions/run-effekt-tests
121110
with:
122-
node-version: ${{ env.NODE_VERSION }}
123-
124-
- name: Install Chez Scheme, LLVM & libuv
125-
run: sudo apt-get install -y chezscheme llvm-15 libuv1-dev
126-
127-
- name: Run tests with retry
128-
uses: nick-fields/retry@v3
129-
with:
130-
timeout_minutes: 120 # NOTE: This needs _some_ value. As of writing this, 2 hours should be future-proof. :)
131-
max_attempts: 3
132-
retry_on: error
133-
command: sbt clean test
134-
new_command_on_retry: sbt testQuick # should only rerun failed tests
111+
full-test: 'true'
112+
use-retry: 'true'
113+
# Since we're on 'master', we can assume that the tests already passed.
114+
# Therefore retrying is OK (to prevent flaky tests from cancelling the deploy).
135115

136116
set-version:
137117
name: Bump Version
@@ -145,15 +125,7 @@ jobs:
145125
with:
146126
submodules: 'true'
147127

148-
- name: Set up JDK ${{ env.JAVA_VERSION }}
149-
uses: actions/setup-java@v4
150-
with:
151-
java-version: ${{ env.JAVA_VERSION }}
152-
distribution: 'zulu'
153-
cache: 'sbt'
154-
155-
- name: Setup SBT
156-
uses: sbt/setup-sbt@v1
128+
- uses: ./.github/actions/setup-effekt
157129

158130
- name: Bump Effekt version using sbt
159131
id: set-version

.github/workflows/ci.yml

Lines changed: 10 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
name: Continuous Integration
1+
name: CI
22

33
on:
44
push:
55
branches:
66
- master
77
pull_request:
88

9-
env:
10-
JAVA_VERSION: '11'
11-
NODE_VERSION: '16.x'
12-
139
jobs:
1410
run-hello-world:
1511
strategy:
@@ -23,23 +19,11 @@ jobs:
2319
with:
2420
submodules: 'true'
2521

26-
- name: Set up JDK ${{ env.JAVA_VERSION }}
27-
uses: actions/setup-java@v4
28-
with:
29-
java-version: ${{ env.JAVA_VERSION }}
30-
distribution: 'zulu'
31-
cache: 'sbt'
32-
33-
- name: Setup SBT
34-
uses: sbt/setup-sbt@v1
22+
- uses: ./.github/actions/setup-effekt
3523

36-
- name: Set up NodeJS ${{ env.NODE_VERSION }}
37-
uses: actions/setup-node@v4
24+
- uses: ./.github/actions/run-effekt-tests
3825
with:
39-
node-version: ${{ env.NODE_VERSION }}
40-
41-
- name: Run tests
42-
run: sbt "effektJVM/clean; effektJVM/testOnly effekt.JavaScriptTests -- --tests=.*examples[\\/]*pos[\\/]*sideeffects.*; effektJVM/testOnly effekt.JavaScriptTests -- --tests=.*examples[\\/]*neg[\\/]*coverage.*"
26+
full-test: 'false'
4327

4428
build-jar:
4529
strategy:
@@ -53,48 +37,12 @@ jobs:
5337
with:
5438
submodules: 'true'
5539

56-
- name: Set up JDK ${{ env.JAVA_VERSION }}
57-
uses: actions/setup-java@v4
40+
- uses: ./.github/actions/setup-effekt
5841
with:
59-
java-version: ${{ env.JAVA_VERSION }}
60-
distribution: 'zulu'
61-
cache: 'sbt'
62-
63-
- name: Setup SBT
64-
uses: sbt/setup-sbt@v1
65-
66-
- name: Update apt database
67-
if: matrix.os != 'windows-latest'
68-
run: sudo apt-get update
69-
70-
- name: Install Chez Scheme
71-
if: matrix.os != 'windows-latest'
72-
run: sudo apt-get install chezscheme
42+
install-dependencies: 'true'
43+
install-valgrind: 'true'
7344

74-
- name: Install LLVM 15
75-
if: matrix.os != 'windows-latest'
76-
run: sudo apt-get install llvm-15
77-
78-
- name: Install Valgrind
79-
if: matrix.os != 'windows-latest'
80-
run: sudo apt-get install valgrind
81-
82-
- name: Install libuv
83-
run: sudo apt-get install libuv1-dev
84-
85-
- name: Set up NodeJS ${{ env.NODE_VERSION }}
86-
uses: actions/setup-node@v4
45+
- uses: ./.github/actions/run-effekt-tests
8746
with:
88-
node-version: ${{ env.NODE_VERSION }}
89-
90-
- name: Run tests
91-
run: EFFEKT_VALGRIND=1 EFFEKT_DEBUG=1 sbt -J-Xss1G clean test
92-
93-
- name: Assemble fully optimized js file
94-
run: sbt effektJS/fullOptJS
95-
96-
- name: Try installing effekt binary
97-
run: sbt install
98-
99-
- name: Run effekt binary
100-
run: effekt.sh --help
47+
full-test: 'true'
48+
use-retry: 'false'

.github/workflows/deploy.yml

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# This is a copy-and-paste version of ci.yml but additionally creating a release
21
name: Release Artifacts
32

43
on:
@@ -10,10 +9,6 @@ on:
109
types:
1110
- completed
1211

13-
env:
14-
JAVA_VERSION: '11'
15-
NODE_VERSION: '16.x'
16-
1712
jobs:
1813
build-jar:
1914
name: Build and assemble the Effekt compiler
@@ -30,20 +25,7 @@ jobs:
3025
fetch-depth: 0
3126
submodules: 'true'
3227

33-
- name: Set up JDK ${{ env.JAVA_VERSION }}
34-
uses: actions/setup-java@v4
35-
with:
36-
java-version: ${{ env.JAVA_VERSION }}
37-
distribution: 'zulu'
38-
cache: 'sbt'
39-
40-
- name: Setup SBT
41-
uses: sbt/setup-sbt@v1
42-
43-
- name: Set up NodeJS ${{ env.NODE_VERSION }}
44-
uses: actions/setup-node@v4
45-
with:
46-
node-version: ${{ env.NODE_VERSION }}
28+
- uses: ./.github/actions/setup-effekt
4729

4830
- name: Get the version
4931
id: get_version

0 commit comments

Comments
 (0)