Skip to content

Commit

Permalink
Merge pull request #2 from sifive/wake-extras-ci
Browse files Browse the repository at this point in the history
Add Basic CI checks
  • Loading branch information
V-FEXrt authored Nov 9, 2023
2 parents f65d377 + 9be2783 commit bb9e17d
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 1 deletion.
35 changes: 35 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "Run Tests"

on:
pull_request:
push:
branches:
- main

jobs:
test:
runs-on: ubuntu-22.04
name: Run Tests
steps:
- name: Clone wake-extras
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Download wake
run: wget https://github.com/sifive/wake/releases/download/v39.1.0/ubuntu-22-04-wake_39.1.0-1_amd64.deb

- name: Install wake
run: sudo apt-get install ./ubuntu-22-04-wake_39.1.0-1_amd64.deb

- name: Initialize wake
run: wake --init .

- name: Typecheck wake
run: wake -x 'Unit'

- name: Check formatting
run: wake-format --dry-run --auto

- name: Run tests
run: ./tests/test.sh
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/**/wake.db*
/**/wake.log
2 changes: 1 addition & 1 deletion json.wake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package json

from wake import _
from utils import prefixError
from result import prefixError
from query import _

# Anyone who depends on json will also
Expand Down
17 changes: 17 additions & 0 deletions result.wake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package result

# When `result` is Fail, prefixes the internal error message with `prefix`
#
# Parameters:
# - `prefix`: The message to prepend to `result`
# - `result`: The Result which may be prepended to
#
# Examples:
# ```
# prefixError "foo" (Pass 123) -> Pass 123
# prefixError "foo" (Fail (Error "bar" stack)) => Fail (Error "foobar" stack)
# ```
export def prefixError (prefix: String): (result: Result a Error) => Result a Error = match _
Pass r -> Pass r
Fail (Error msg stack) -> Fail (Error "{prefix}{msg}" stack)

10 changes: 10 additions & 0 deletions tests/query.wake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package tests

from wake import _
from query import _

export def runQueryTests _ =
require 4, Nil = single 4
else failWithError "Unexpected value for single"

Pass Unit
5 changes: 5 additions & 0 deletions tests/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /bin/bash

set -ex

wake --in tests runQueryTests

0 comments on commit bb9e17d

Please sign in to comment.