From 74d3ff4bdcbc4706c3e396f48a29185633229a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Thu, 11 Jul 2024 10:13:26 +0200 Subject: [PATCH] github: Bump Go and Sass versions, add Staticcheck --- .github/workflows/test.yml | 8 ++++++-- transpiler_test.go | 24 +++++------------------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d632398..07ec16e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,12 +4,12 @@ on: pull_request: name: Test env: - SASS_VERSION: 1.63.2 + SASS_VERSION: 1.77.5 jobs: test: strategy: matrix: - go-version: [~1.19, ~1.20] + go-version: [1.21.x, 1.22.x] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: @@ -17,6 +17,8 @@ jobs: uses: actions/setup-go@v3 with: go-version: ${{ matrix.go-version }} + - name: Install staticcheck + run: go install honnef.co/go/tools/cmd/staticcheck@latest - name: Checkout code uses: actions/checkout@v3 - name: Install dart-sass Linux @@ -38,6 +40,8 @@ jobs: curl -LJO "https://github.com/sass/dart-sass/releases/download/${env:SASS_VERSION}/dart-sass-${env:SASS_VERSION}-windows-x64.zip"; Expand-Archive -Path "dart-sass-${env:SASS_VERSION}-windows-x64.zip" -DestinationPath .; echo "DART_SASS_BINARY=$env:GITHUB_WORKSPACE/dart-sass/sass.bat" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append + - name: Staticcheck + run: staticcheck ./... - name: Test run: go test -race . -coverprofile=coverage.txt -covermode=atomic - name: Upload coverage diff --git a/transpiler_test.go b/transpiler_test.go index 999cc12..d785f51 100644 --- a/transpiler_test.go +++ b/transpiler_test.go @@ -1,10 +1,8 @@ package godartsass_test import ( - "encoding/json" "errors" "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -63,7 +61,6 @@ func (t testImportResolver) Load(url string) (godartsass.Import, error) { panic("protocol error") } return godartsass.Import{Content: t.content, SourceSyntax: t.sourceSyntax}, nil - } func TestTranspilerVariants(t *testing.T) { @@ -179,19 +176,17 @@ body { } func TestIncludePaths(t *testing.T) { - dir1, _ := ioutil.TempDir(os.TempDir(), "libsass-test-include-paths-dir1") - defer os.RemoveAll(dir1) - dir2, _ := ioutil.TempDir(os.TempDir(), "libsass-test-include-paths-dir2") - defer os.RemoveAll(dir2) + dir1 := t.TempDir() + dir2 := t.TempDir() colors := filepath.Join(dir1, "_colors.scss") content := filepath.Join(dir2, "_content.scss") - ioutil.WriteFile(colors, []byte(` + os.WriteFile(colors, []byte(` $moo: #f442d1 !default; `), 0o644) - ioutil.WriteFile(content, []byte(` + os.WriteFile(content, []byte(` content { color: #ccc; } `), 0o644) @@ -330,7 +325,6 @@ div { color: $primary-color; }`, gor) wg.Wait() c.Assert(transpiler.IsShutDown(), qt.Equals, true) - } func BenchmarkTranspiler(b *testing.B) { @@ -414,7 +408,7 @@ func TestVersion(t *testing.T) { version, err := godartsass.Version(getSassEmbeddedFilename()) c.Assert(err, qt.IsNil) c.Assert(version, qt.Not(qt.Equals), "") - c.Assert(version.ProtocolVersion, qt.Equals, "2.0.0") + c.Assert(version.ProtocolVersion, qt.Equals, "2.7.1") } func newTestTranspiler(c *qt.C, opts godartsass.Options) (*godartsass.Transpiler, func()) { @@ -436,11 +430,3 @@ func getSassEmbeddedFilename() string { return "sass" } - -// used for debugging -func printJSON(s string) { - m := make(map[string]interface{}) - json.Unmarshal([]byte(s), &m) - b, _ := json.MarshalIndent(m, "", " ") - fmt.Printf("%s", b) -}