Fork of daniellemaywood.uk/gleam — Wasm codegen work
1name: ci
2on:
3 pull_request:
4 push:
5 branches:
6 - main
7jobs:
8 test:
9 env:
10 RUSTFLAGS: "-D warnings"
11 name: test
12 runs-on: ${{ matrix.os }}
13 strategy:
14 matrix:
15 toolchain: [stable]
16 build: [linux-amd64, macos, windows]
17 include:
18 - build: linux-amd64
19 os: ubuntu-latest
20 target: x86_64-unknown-linux-gnu
21 - build: macos
22 os: macos-latest
23 target: x86_64-apple-darwin
24 - build: windows
25 os: windows-latest
26 target: x86_64-pc-windows-msvc
27 steps:
28 - name: Checkout repository
29 uses: actions/checkout@v2
30
31 - name: Install Rust toolchain
32 uses: actions-rs/toolchain@v1
33 with:
34 toolchain: ${{ matrix.toolchain }}
35 target: ${{ matrix.target }}
36 profile: minimal
37 override: true
38
39 - name: Build binary
40 uses: actions-rs/cargo@v1
41 with:
42 command: build
43 args: --release --target ${{ matrix.target }}
44
45 - name: Run linter
46 uses: actions-rs/cargo@v1
47 with:
48 command: clippy
49 args: --workspace --target ${{ matrix.target }} -- -D warnings
50
51 - name: Run tests
52 uses: actions-rs/cargo@v1
53 with:
54 command: test
55 args: --workspace --target ${{ matrix.target }}
56
57 - name: Upload artifact (Ubuntu)
58 if: matrix.build == 'linux-amd64'
59 uses: actions/upload-artifact@v2
60 with:
61 name: gleam
62 path: target/${{ matrix.target }}/release/gleam
63
64 test-musl:
65 runs-on: ubuntu-latest
66 container: clux/muslrust:stable
67 steps:
68 - name: Checkout repository
69 uses: actions/checkout@v2
70
71 - name: Link to predefined musl toolchain
72 run: |
73 ln -s /root/.cargo $HOME/.cargo
74 ln -s /root/.rustup $HOME/.rustup
75
76 - name: Build binary
77 run: cargo build --release
78
79 - name: Run tests
80 run: cargo test --workspace
81
82 rustfmt:
83 name: rustfmt
84 runs-on: ubuntu-latest
85 steps:
86 - name: Checkout repository
87 uses: actions/checkout@v2
88
89 - name: Install Rust toolchain
90 uses: actions-rs/toolchain@v1
91 with:
92 toolchain: stable
93 override: true
94 profile: minimal
95 components: rustfmt
96
97 - name: Check formatting
98 run: cargo fmt --all -- --check
99
100 validate-deps:
101 name: validate-deps
102 runs-on: ubuntu-latest
103 steps:
104 - name: Checkout repository
105 uses: actions/checkout@v2
106
107 - name: Install Rust toolchain
108 uses: actions-rs/toolchain@v1
109 with:
110 toolchain: stable
111 override: true
112 profile: minimal
113 - run: |
114 set -e
115 curl -L https://github.com/EmbarkStudios/cargo-deny/releases/download/0.8.5/cargo-deny-0.8.5-x86_64-unknown-linux-musl.tar.gz | tar xzf -
116 mv cargo-deny-*-x86_64-unknown-linux-musl/cargo-deny cargo-deny
117 echo `pwd` >> $GITHUB_PATH
118 - run: cargo deny check
119
120 test-projects:
121 name: test-projects
122 needs: test
123 runs-on: ubuntu-latest
124 steps:
125 - name: Checkout repository
126 uses: actions/checkout@v2.0.0
127
128 - name: Install Erlang
129 uses: gleam-lang/setup-erlang@v1.1.2
130 with:
131 otp-version: 23.2
132
133 - name: Download Gleam binary from previous job
134 uses: actions/download-artifact@v2
135 with:
136 name: gleam
137 path: ./test
138
139 - name: Configure test projects to use Gleam binary
140 run: |
141 echo $PWD/ >> $GITHUB_PATH
142 chmod +x ./gleam
143 sed -i 's/cargo run --quiet --/gleam/' */rebar.config */Makefile
144 sed -i 's/cargo run --/gleam/' */rebar.config */Makefile
145 working-directory: ./test
146
147 - name: test/project_erlang
148 run: |
149 gleam run
150 gleam test
151 gleam docs build
152 working-directory: ./test/project_erlang
153
154 - name: test/project_javascript
155 run: |
156 gleam run
157 gleam test
158 gleam docs build
159 working-directory: ./test/project_javascript
160
161 - name: test/language Erlang
162 run: make clean erlang
163 working-directory: ./test/language
164
165 - name: test/language JavaScript
166 run: make clean javascript
167 working-directory: ./test/language
168
169 - name: test/rebar_project
170 run: rebar3 eunit
171 working-directory: ./test/rebar_project
172
173 - name: test/compile_package0
174 run: make
175 working-directory: ./test/compile_package0
176
177 - name: test/compile_package1
178 run: make
179 working-directory: ./test/compile_package1
180
181 - name: Test JavaScript prelude
182 run: make
183 working-directory: ./test/javascript_prelude
184
185 - name: Test lib template
186 run: |
187 gleam new lib_project --template=lib
188 cd lib_project
189 gleam run
190 gleam test
191 gleam docs build
192
193 # Assert that module metadata has been written
194 ls build/dev/erlang/lib_project/build/lib_project.gleam_module
195
196 # Assert that HTML docs have been written
197 ls build/dev/docs/lib_project/index.html
198 ls build/dev/docs/lib_project/index.css
199 ls build/dev/docs/lib_project/gleam.mjs
200 ls build/dev/docs/lib_project/index.html
201 ls build/dev/docs/lib_project/lib_project.html