From babd778850b4bcd392a5216e5486f1f55ca2cce2 Mon Sep 17 00:00:00 2001 From: Reinhard Stahn <51020828+rainij@users.noreply.github.com> Date: Tue, 10 May 2022 14:21:01 +0200 Subject: [PATCH] Remove bad makefile target gha (#199) * Updated workflow 'ci' and deleted 'ci-pull-request' * Deleted makefile target 'gha' and its companion 'debug'. * Fix failing test for exercise 'binary' (applied './bin/generate --test-only binary') --- .github/workflows/ci-pull-request.yml | 30 ---------------------- .github/workflows/ci.yml | 11 ++++---- Makefile | 26 ------------------- exercises/practice/binary/test.sml | 36 +++++++++++++-------------- 4 files changed, 23 insertions(+), 80 deletions(-) delete mode 100644 .github/workflows/ci-pull-request.yml diff --git a/.github/workflows/ci-pull-request.yml b/.github/workflows/ci-pull-request.yml deleted file mode 100644 index 5c1537b..0000000 --- a/.github/workflows/ci-pull-request.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: sml / pull_request - -on: - pull_request: - workflow_dispatch: - -jobs: - ci: - runs-on: ubuntu-latest - - strategy: - matrix: - sml-version: [5.8] - - steps: - - uses: actions/checkout@v3 - - - 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 - - echo $HOME/.local/bin/ >> $GITHUB_PATH - - - name: Run exercism/sml ci (runs tests) for all exercises - env: - GITHUB_COMMIT_RANGE: origin/${{ github.base_ref }}..${{ github.sha }} - run: | - git fetch origin ${{ github.base_ref }} - make gha diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2364fa..1d2f33f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,7 @@ -name: sml / main +name: sml / ci on: + pull_request: push: branches: [master, main] workflow_dispatch: @@ -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 diff --git a/Makefile b/Makefile index f030379..a658f08 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/exercises/practice/binary/test.sml b/exercises/practice/binary/test.sml index 6a04690..679df6b 100644 --- a/exercises/practice/binary/test.sml +++ b/exercises/practice/binary/test.sml @@ -1,7 +1,5 @@ -(* version 1.0.0 *) - use "testlib.sml"; -use "example.sml"; +use "binary.sml"; infixr |> fun x |> f = f x @@ -9,49 +7,49 @@ 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 \ No newline at end of file