Skip to content

Commit 7058b17

Browse files
Merge pull request #16 from dillonkearns/setup-ci
Setup CI
2 parents b39971f + 85bdd3b commit 7058b17

7 files changed

Lines changed: 657 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
main:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v5
17+
- name: Use Node.js 24
18+
uses: actions/setup-node@v6
19+
with:
20+
node-version: 24
21+
# Re-use node_modules between runs until package-lock.json changes.
22+
- name: Cache node_modules
23+
id: cache-node_modules
24+
uses: actions/cache@v4
25+
with:
26+
path: node_modules
27+
key: node_modules-${{ hashFiles('package-lock.json') }}
28+
29+
# Re-use ~/.elm between runs until elm.json or
30+
# review/elm.json changes. The Elm compiler saves downloaded Elm packages
31+
# to ~/.elm, and elm-tooling saves downloaded tool executables there.
32+
- name: Cache ~/.elm
33+
uses: actions/cache@v4
34+
with:
35+
path: ~/.elm
36+
key: elm-${{ hashFiles('elm.json', 'review/elm.json') }}
37+
38+
# Install npm packages, unless we restored them from cache.
39+
# Since `npm ci` removes the node_modules folder before running it’s
40+
# important to skip this step if cache was restored.
41+
- name: npm ci
42+
if: steps.cache-node_modules.outputs.cache-hit != 'true'
43+
run: npm ci
44+
- name: elm-tooling install
45+
run: npx --no-install elm-tooling install
46+
- name: Tests
47+
run: npm test
48+
# - name: Run elm-review
49+
# run: npx elm-review
50+
- name: elm-format
51+
run: npx --no-install elm-format --validate $(git ls-files '*.elm')

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea
22
elm-stuff
3-
docs.json
3+
docs.json
4+
node_modules

example/counter/readme.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22

33
This app is copied from the [counter example](https://github.com/lamdera/example-apps/tree/master/counter) and modified to use `lamdera/program-test`.
44

5-
There's an end-to-end test written for it which you can view by starting lamdera live in this folder and going to http://localhost:8000/tests/EndToEndTests.elm
5+
There's an end-to-end test written for it which you can view by starting lamdera live in this folder and going to http://localhost:8000/tests/EndToEndTests.elm
6+
7+
You can also run the test suite in the browser with this command:
8+
9+
```bash
10+
elm-test --compiler `which lamdera`
11+
```

example/counter/src/Env.elm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ module Env exposing (..)
55

66

77
dummyConfigItem =
8-
""
8+
""

example/counter/tests/EndToEndTests.elm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Tests exposing (main)
1+
module EndToEndTests exposing (main, suite)
22

33
import Backend
44
import Effect.Browser.Dom as Dom
@@ -10,6 +10,7 @@ import Effect.Test exposing (FileUpload(..), HttpResponse(..), MultipleFilesUplo
1010
import Effect.Time
1111
import Frontend
1212
import Html
13+
import Test exposing (Test)
1314
import Test.Html.Query
1415
import Test.Html.Selector
1516
import Types exposing (BackendModel, BackendMsg, FrontendModel, FrontendMsg, ToBackend, ToFrontend)
@@ -71,6 +72,13 @@ tests =
7172
]
7273

7374

75+
suite : Test
76+
suite =
77+
tests
78+
|> List.map Effect.Test.toTest
79+
|> Test.describe "suite"
80+
81+
7482
main : Program () (Effect.Test.Model ToBackend FrontendMsg FrontendModel ToFrontend BackendMsg BackendModel) (Effect.Test.Msg ToBackend FrontendMsg FrontendModel ToFrontend BackendMsg BackendModel)
7583
main =
7684
Effect.Test.viewer tests

0 commit comments

Comments
 (0)