Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Basic CI checks #2

Merged
merged 12 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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: Check formatting
run: wake-format --dry-run --auto
JakeSiFive marked this conversation as resolved.
Show resolved Hide resolved

- name: Run tests
run: ./tests/test.sh
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