gleam/.github/workflows/ci.yaml
2021-11-13 19:22:22 +00:00

195 lines
5.1 KiB
YAML

name: ci
on:
pull_request:
push:
branches:
- main
jobs:
test:
env:
RUSTFLAGS: "-D warnings"
name: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
toolchain: [stable]
build: [linux-amd64, macos, windows]
include:
- build: linux-amd64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- build: macos
os: macos-latest
target: x86_64-apple-darwin
- build: windows
os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.target }}
profile: minimal
override: true
- name: Build binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}
- name: Run linter
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --target ${{ matrix.target }} -- -D warnings
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --target ${{ matrix.target }}
- name: Upload artifact (Ubuntu)
if: matrix.build == 'linux-amd64'
uses: actions/upload-artifact@v2
with:
name: gleam
path: target/${{ matrix.target }}/release/gleam
test-musl:
runs-on: ubuntu-latest
container: clux/muslrust:stable
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Link to predefined musl toolchain
run: |
ln -s /root/.cargo $HOME/.cargo
ln -s /root/.rustup $HOME/.rustup
- name: Build binary
run: cargo build --release
- name: Run tests
run: cargo test --workspace
rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
validate-deps:
name: validate-deps
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
- run: |
set -e
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 -
mv cargo-deny-*-x86_64-unknown-linux-musl/cargo-deny cargo-deny
echo `pwd` >> $GITHUB_PATH
- run: cargo deny check
test-projects:
name: test-projects
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2.0.0
- name: Install Erlang
uses: gleam-lang/setup-erlang@v1.1.2
with:
otp-version: 23.2
- name: Download Gleam binary from previous job
uses: actions/download-artifact@v2
with:
name: gleam
path: ./test
- name: Configure test projects to use Gleam binary
run: |
echo $PWD/ >> $GITHUB_PATH
chmod +x ./gleam
sed -i 's/cargo run --quiet --/gleam/' */rebar.config */Makefile
sed -i 's/cargo run --/gleam/' */rebar.config */Makefile
working-directory: ./test
- name: test/language Erlang
run: make clean erlang
working-directory: ./test/language
- name: test/language JavaScript
run: make clean javascript
working-directory: ./test/language
- name: test/rebar_project
run: rebar3 eunit
working-directory: ./test/rebar_project
- name: test/compile_package0
run: make
working-directory: ./test/compile_package0
- name: test/compile_package1
run: make
working-directory: ./test/compile_package1
- name: test/project
working-directory: ./test/project
run: |
gleam deps download
gleam run
gleam test
- name: Test lib template
run: |
gleam new lib_project --template=lib
cd lib_project
gleam run
gleam test
gleam docs build
# Assert that module metadata has been written
ls build/dev/erlang/lib_project/lib_project.gleam_module
# Assert that HTML docs have been written
ls build/dev/docs/lib_project/index.html
ls build/dev/docs/lib_project/index.css
ls build/dev/docs/lib_project/gleam.js
ls build/dev/docs/lib_project/index.html
ls build/dev/docs/lib_project/lib_project.html
- name: Test JavaScript prelude
run: |
cd test/javascript_prelude
npm test