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

Remove bad makefile target gha #199

Merged
merged 3 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
30 changes: 0 additions & 30 deletions .github/workflows/ci-pull-request.yml

This file was deleted.

11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: sml / main
name: sml / ci

on:
pull_request:
push:
branches: [master, main]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you'd like, you could do a follow-up PR to change this to:

Suggested change
branches: [master, main]
branches: [main]

We've moved to using main for all repos.

workflow_dispatch:
Expand All @@ -16,12 +17,12 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install project dependencies
- name: Install sml-${{ matrix.sml-version }}
run: |
curl -LO https://github.com/polyml/polyml/archive/v${{ matrix.sml-version }}.tar.gz
tar xf v${{ matrix.sml-version }}.tar.gz
cd polyml-${{ matrix.sml-version }} && ./configure --prefix=$HOME/.local && make && make install && cd -
export PATH=$PATH:$HOME/.local/bin
echo "$HOME/.local/bin/" >> $GITHUB_PATH

- name: Run exercism/sml ci (runs tests) for all exercises
run: make gha
- name: Run tests for all exercises
run: make test
26 changes: 0 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,8 @@
dirs := $(wildcard exercises/practice/*)
all-tests := $(addprefix test-, $(notdir $(dirs)))

COMMIT_RANGE := HEAD
ifdef GITHUB_COMMIT_RANGE
COMMIT_RANGE := $(GITHUB_COMMIT_RANGE)
endif

test: $(all-tests)

debug:
@echo ---------------
@echo HEAD: $(shell git rev-list -1 HEAD)
@echo master: $(shell git rev-list -1 origin/master 2> /dev/null)
@echo COMMIT_RANGE: $(COMMIT_RANGE)
@echo GITHUB_EVENT_NAME: $(GITHUB_EVENT_NAME)
@echo GITHUB_SHA: $(GITHUB_SHA)
@echo Modified/Added:
@git diff-tree --name-status -r --no-commit-id --diff-filter=AM -M $(COMMIT_RANGE)
@echo Renamed:
@git diff-tree --name-status -r --no-commit-id --diff-filter=R -M $(COMMIT_RANGE)
@echo ---------------

gha:
@$(MAKE) -s debug
$(eval tests := $(shell \
git diff-tree --name-only -r --diff-filter=AM $(COMMIT_RANGE) | \
perl -n -e '/exercises\/practice\/([a-z-_]+)\/.+\.sml/ && print "test-$$1\n"' | uniq))
$(if $(tests), @echo Tests: $(tests), @echo 'Nothing to test.')
$(if $(tests), @$(MAKE) -s $(tests))

test-%:
$(eval exercise := $(patsubst test-%, %, $@))
@echo
Expand Down
36 changes: 17 additions & 19 deletions exercises/practice/binary/test.sml
Original file line number Diff line number Diff line change
@@ -1,57 +1,55 @@
(* version 1.0.0 *)

use "testlib.sml";
use "example.sml";
use "binary.sml";

infixr |>
fun x |> f = f x

val testsuite =
describe "binary" [
test "binary 0 is decimal 0"
(fn _ => decimal ("0") |> Expect.equalTo (SOME 0)),
(fn _ => decimal "0" |> Expect.equalTo (SOME 0)),

test "binary 1 is decimal 1"
(fn _ => decimal ("1") |> Expect.equalTo (SOME 1)),
(fn _ => decimal "1" |> Expect.equalTo (SOME 1)),

test "binary 10 is decimal 2"
(fn _ => decimal ("10") |> Expect.equalTo (SOME 2)),
(fn _ => decimal "10" |> Expect.equalTo (SOME 2)),

test "binary 11 is decimal 3"
(fn _ => decimal ("11") |> Expect.equalTo (SOME 3)),
(fn _ => decimal "11" |> Expect.equalTo (SOME 3)),

test "binary 100 is decimal 4"
(fn _ => decimal ("100") |> Expect.equalTo (SOME 4)),
(fn _ => decimal "100" |> Expect.equalTo (SOME 4)),

test "binary 1001 is decimal 9"
(fn _ => decimal ("1001") |> Expect.equalTo (SOME 9)),
(fn _ => decimal "1001" |> Expect.equalTo (SOME 9)),

test "binary 11010 is decimal 26"
(fn _ => decimal ("11010") |> Expect.equalTo (SOME 26)),
(fn _ => decimal "11010" |> Expect.equalTo (SOME 26)),

test "binary 10001101000 is decimal 1128"
(fn _ => decimal ("10001101000") |> Expect.equalTo (SOME 1128)),
(fn _ => decimal "10001101000" |> Expect.equalTo (SOME 1128)),

test "binary ignores leading zeros"
(fn _ => decimal ("000011111") |> Expect.equalTo (SOME 31)),
(fn _ => decimal "000011111" |> Expect.equalTo (SOME 31)),

test "2 is not a valid binary digit"
(fn _ => decimal ("2") |> Expect.equalTo NONE),
(fn _ => decimal "2" |> Expect.equalTo NONE),

test "a number containing a non-binary digit is invalid"
(fn _ => decimal ("01201") |> Expect.equalTo NONE),
(fn _ => decimal "01201" |> Expect.equalTo NONE),

test "a number with trailing non-binary characters is invalid"
(fn _ => decimal ("10nope") |> Expect.equalTo NONE),
(fn _ => decimal "10nope" |> Expect.equalTo NONE),

test "a number with leading non-binary characters is invalid"
(fn _ => decimal ("nope10") |> Expect.equalTo NONE),
(fn _ => decimal "nope10" |> Expect.equalTo NONE),

test "a number with internal non-binary characters is invalid"
(fn _ => decimal ("10nope10") |> Expect.equalTo NONE),
(fn _ => decimal "10nope10" |> Expect.equalTo NONE),

test "a number and a word whitespace spearated is invalid"
(fn _ => decimal ("001 nope") |> Expect.equalTo NONE)
test "a number and a word whitespace separated is invalid"
(fn _ => decimal "001 nope" |> Expect.equalTo NONE)
]

val _ = Test.run testsuite