Skip to content

Commit

Permalink
GHA: Enable Go toml-test based test suite (#50)
Browse files Browse the repository at this point in the history
* GHA: Set GOPATH

* GHA: Print go version

* GHA: Attempt to fix GOPATH

https://laszlo.cloud/setting-gopath-in-github-actions

* GHA: Attempt 2 to fix GOPATH

https://github.com/golang/go/wiki/SettingGOPATH#go-113

* GHA: Try getting rid of GOPATH

* GHA: Install toml-test

* GHA: Require go version 1.16.5

This was the latest stable go version when this was committed.

* GHA: Fix .yml

* GHA: Specify the version of toml-test to be installed

* GHA: Separate 'uses' and 'run'

Looks like GHA doesn't work if both are in the same yml node.

* GHA: Looks like we do need to set GOPATH

* GHA: Install an older version of toml-test that installs binary

* Update to use tests for TOML 1.0.0

* GHA: Add skips for failing TOML v1.0.0 tests

Ref: #40

* GHA: Disable testing on macos

It fails with these errors:

    go: writing stat cache: mkdir /home/runner: operation not supported
    go: writing stat cache: mkdir /home/runner: operation not supported
    go: downloading github.com/BurntSushi/toml-test v0.1.1-0.20210628215546-8c0aa6d9c74f
    go get github.com/BurntSushi/toml-test/cmd/toml-test@master: mkdir /home/runner: operation not supported
    stack trace: (most recent call last)
    /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/nimblecache-946033505/nimscriptapi_610282258.nim(187, 16)
    /Users/runner/work/parsetoml/parsetoml/parsetoml.nimble(36, 7) run_toml_test_with_skipsTask
    /Users/runner/work/parsetoml/parsetoml/nim/lib/system/nimscript.nim(273, 7) exec
    /Users/runner/work/parsetoml/parsetoml/nim/lib/system/nimscript.nim(273, 7) Error: unhandled exception: FAILED: go get -u -v github.com/BurntSushi/toml-test/cmd/toml-test@master [OSError]

* Add few comments about incompatibility with TOML v1.0.0

* GHA: Disable testing on Windows

* GHA: Get rid of GOPATH dependency

Assumption is that $GOPATH/bin is auto-added to $PATH.

* Skip a test for now; it's failing on Windows

Ref:
- #51
- https://github.com/NimParsers/parsetoml/pull/50/checks?check_run_id=2966348113
  • Loading branch information
kaushalmodi authored Jul 1, 2021
1 parent 64842da commit 83de3f3
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 16 deletions.
25 changes: 21 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,21 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
# os: [ubuntu-latest, windows-latest, macos-latest]
# Fails on macos with this error
# go: writing stat cache: mkdir /home/runner: operation not supported
# go: writing stat cache: mkdir /home/runner: operation not supported
# go: downloading github.com/BurntSushi/toml-test v0.1.1-0.20210628215546-8c0aa6d9c74f
# go get github.com/BurntSushi/toml-test/cmd/toml-test@master: mkdir /home/runner: operation not supported
# stack trace: (most recent call last)
# /private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/nimblecache-946033505/nimscriptapi_610282258.nim(187, 16)
# /Users/runner/work/parsetoml/parsetoml/parsetoml.nimble(36, 7) run_toml_test_with_skipsTask
# /Users/runner/work/parsetoml/parsetoml/nim/lib/system/nimscript.nim(273, 7) exec
# /Users/runner/work/parsetoml/parsetoml/nim/lib/system/nimscript.nim(273, 7) Error: unhandled exception: FAILED: go get -u -v github.com/BurntSushi/toml-test/cmd/toml-test@master [OSError]
os: [ubuntu-latest, windows-latest]
nim: ['devel', 'version-1-4']
steps:
- uses: actions/checkout@v2
# - uses: actions/setup-go@v2 # For 'nimble run_toml_test'
- uses: alaviss/[email protected]
with:
path: 'nim'
Expand All @@ -29,7 +39,14 @@ jobs:
run: nimble install --depsOnly --accept
- name: Pull kaushalmodi's global config.nims # For 'nim test'
run: nim pullConfig
- name: Run tests
- name: Run Nim tests
run: nim test
- uses: actions/setup-go@v2
with:
go-version: '1.16.5'
- name: Run Go tests
run: |
nim test
go version
# https://github.com/NimParsers/parsetoml/issues/40
# nimble run_toml_test
nimble run_toml_test_with_skips
74 changes: 62 additions & 12 deletions parsetoml.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,77 @@ skipDirs = @["decoder"]
requires "nim >= 0.18.0"

from os import `/`, expandTilde
from strutils import `%`

task run_toml_test, "Validates parsetoml using toml-test":
exec("nim c -d:release decoder/decoder.nim")
# Needs "go" executable to be present in PATH.
# In GHA, add "- uses: actions/setup-go@v2"
let
goPath = getEnv("GOPATH")
tomlTestRepo = "github.com/BurntSushi/toml-test"
doAssert goPath != ""
tomlTestRepo = "github.com/BurntSushi/toml-test/cmd/toml-test@master"
exec("go get -u -v " & tomlTestRepo)
exec((goPath / "bin" / "toml-test") & " " & "decoder/decoder")
exec("toml-test decoder/decoder")

task run_new_toml_test, "Validates parsetoml using toml-test from sgarciac":
exec("nim c -d:release -d:newtestsuite decoder/decoder.nim")
# https://github.com/NimParsers/parsetoml/issues/40
# FIXME: Delete below task once above issue is fixed
# i.e. parsetoml starts supporting TOML v1.0.0.
task run_toml_test_with_skips, "Validates parsetoml using toml-test (with test skips)":
exec("nim c -d:release decoder/decoder.nim")
# Needs "go" executable to be present in PATH.
# In GHA, add "- uses: actions/setup-go@v2"
let
goPath = getEnv("GOPATH")
tomlTestRepo = "github.com/sgarciac/toml-test"
doAssert goPath != ""
tomlTestRepo = "github.com/BurntSushi/toml-test/cmd/toml-test@master"
exec("go get -u -v " & tomlTestRepo)
exec("cp -r " & (goPath / "src" / "github.com" / "sgarciac" / "toml-test") &
" " & (goPath / "src" / "github.com" / "BurntSushi" / "toml-test"))
exec((goPath / "bin" / "toml-test") & " " & "decoder/decoder")
exec("toml-test" &
" -skip valid/array" &
" -skip valid/array-bool" &
" -skip valid/array-empty" &
" -skip valid/array-hetergeneous" &
" -skip valid/array-mixed-int-array" &
" -skip valid/array-mixed-int-float" &
" -skip valid/array-mixed-int-string" &
" -skip valid/array-mixed-string-table" &
" -skip valid/array-nested-double" &
" -skip valid/array-nested" &
" -skip valid/array-nospaces" &
" -skip valid/array-string-quote-comma-2" &
" -skip valid/array-string-quote-comma" &
" -skip valid/array-string-with-comma" &
" -skip valid/array-strings" &
" -skip valid/comment-everywhere" &
" -skip valid/comment-tricky" &
" -skip valid/datetime-local-date" &
" -skip valid/datetime-local-time" &
" -skip valid/example" &
" -skip valid/float-inf-and-nan" &
" -skip valid/float-zero" &
" -skip valid/inline-table-key-dotted" &
" -skip valid/inline-table-nest" &
" -skip valid/multiline-string-quotes" &
" -skip valid/multiline-string" &
" -skip valid/spec-example-1-compact" &
" -skip valid/spec-example-1" &
" -skip invalid/array-missing-separator" &
" -skip invalid/array-of-tables-1" &
" -skip invalid/control-comment-del" &
" -skip invalid/control-comment-lf" &
" -skip invalid/control-comment-null" &
" -skip invalid/control-comment-us" &
" -skip invalid/control-string-bs" &
" -skip invalid/duplicate-table-array2" &
" -skip invalid/encoding-bad-utf8-in-comment" &
" -skip invalid/encoding-bad-utf8-in-string" &
" -skip invalid/encoding-utf16" &
" -skip invalid/inline-table-double-comma" &
" -skip invalid/inline-table-no-comma" &
" -skip invalid/inline-table-trailing-comma" &
" -skip invalid/integer-double-sign-nex" &
" -skip invalid/integer-double-sign-plus" &
" -skip invalid/integer-leading-zero-sign-1" &
" -skip invalid/integer-leading-zero-sign-2" &
" -skip invalid/key-multiline" &
" -skip invalid/string-bad-multiline" &
" -skip invalid/string-multiline-escape-space" &
" -skip invalid/string-multiline-escape-space" &
" -skip valid/float-exponent" & # https://github.com/NimParsers/parsetoml/issues/51
" decoder/decoder")

0 comments on commit 83de3f3

Please sign in to comment.