From 29b5c0e9de30b16bdd3a081f1e07fdf0f5475150 Mon Sep 17 00:00:00 2001 From: Andrey Kuzmin Date: Sun, 24 Mar 2024 11:51:38 +0100 Subject: [PATCH] Use nix --- .github/workflows/gh-pages.yml | 32 +++++------------- .github/workflows/publish.yml | 33 ++++++------------ .github/workflows/test.yml | 26 ++++----------- elm.json | 2 +- examples/src/Tubes.elm | 1 - flake.lock | 61 ++++++++++++++++++++++++++++++++++ flake.nix | 22 ++++++++++++ review/elm.json | 15 +++++---- review/src/ReviewConfig.elm | 2 ++ src/Obj/Decode.elm | 2 +- src/Obj/Encode.elm | 1 - tests/Encoding.elm | 8 ++--- 12 files changed, 124 insertions(+), 81 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index ace64a6..f5023f1 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -8,33 +8,19 @@ jobs: gh-pages: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - run: git config --global user.name "Andrey Kuzmin" - - run: git config --global user.email "unsoundscapes@gmail.com" - - - uses: actions/setup-node@v1 - with: - node-version: "12" + - run: git config --global user.email "hi@unsoundscapes.com" - - uses: actions/cache@v2 + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v22 with: - path: | - ~/.npm - ~/.elm - elm-stuff - key: ${{ runner.os }}-cache - - - run: npm install -g elm@latest-0.19.1 elm-test@0.19.1-revision6 elm-review@2.5.0 elm-format@0.8.5 - - - run: elm-format --validate . - - - run: elm-review - - - run: elm-test + github_access_token: ${{ secrets.GITHUB_TOKEN }} + - run: nix develop --command elm-format --validate . + - run: nix develop --command elm-review + - run: nix develop --command elm-test - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: path: gh-pages ref: gh-pages - - run: ./scripts/gh-pages.sh + - run: nix develop --command ./scripts/gh-pages.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e39a9cd..42c1bd9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,34 +12,21 @@ jobs: test-and-publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - run: git config --global user.name "Andrey Kuzmin" - - run: git config --global user.email "unsoundscapes@gmail.com" - - - uses: actions/setup-node@v1 - with: - node-version: "12" + - run: git config --global user.email "hi@unsoundscapes.com" - - uses: actions/cache@v2 + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v22 with: - path: | - ~/.npm - ~/.elm - key: ${{ runner.os }}-cache - - - run: npm install -g elm@latest-0.19.1 elm-test@0.19.1-revision6 elm-review@2.5.0 elm-format@0.8.5 - - - run: elm-format --validate . - - - run: elm-review - - - run: elm-test + github_access_token: ${{ secrets.GITHUB_TOKEN }} + - run: nix develop --command elm-format --validate . + - run: nix develop --command elm-review + - run: nix develop --command elm-test - - run: ./scripts/elm-publish.sh ${{ github.event.inputs.version }} + - run: nix develop --command ./scripts/elm-publish.sh ${{ github.event.inputs.version }} - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: path: gh-pages ref: gh-pages - - run: ./scripts/gh-pages.sh ${{ github.event.inputs.version }} + - run: nix develop --command ./scripts/gh-pages.sh ${{ github.event.inputs.version }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e4f61f..666d9e2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,24 +8,10 @@ jobs: elm-test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-node@v1 - with: - node-version: "12" - - - uses: actions/cache@v2 + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v22 with: - path: | - ~/.npm - ~/.elm - elm-stuff - key: ${{ runner.os }}-cache - - - run: npm install -g elm@latest-0.19.1 elm-test@0.19.1-revision6 elm-review@2.5.0 elm-format@0.8.5 - - - run: elm-format --validate . - - - run: elm-review - - - run: elm-test + github_access_token: ${{ secrets.GITHUB_TOKEN }} + - run: nix develop --command elm-format --validate . + - run: nix develop --command elm-review + - run: nix develop --command elm-test diff --git a/elm.json b/elm.json index f017164..5261906 100644 --- a/elm.json +++ b/elm.json @@ -17,6 +17,6 @@ "ianmackenzie/elm-units": "2.7.0 <= v < 3.0.0" }, "test-dependencies": { - "elm-explorations/test": "1.2.2 <= v < 2.0.0" + "elm-explorations/test": "2.2.0 <= v < 3.0.0" } } diff --git a/examples/src/Tubes.elm b/examples/src/Tubes.elm index f3f3470..ad07e46 100644 --- a/examples/src/Tubes.elm +++ b/examples/src/Tubes.elm @@ -10,7 +10,6 @@ import Axis3d import BoundingBox3d exposing (BoundingBox3d) import Browser import Camera3d -import Circle2d exposing (boundingBox) import Color import Direction3d import File.Download diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..2921cfd --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1711124224, + "narHash": "sha256-l0zlN/3CiodvWDtfBOVxeTwYSRz93muVbXWSpaMjXxM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "56528ee42526794d413d6f244648aaee4a7b56c0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d64ddda --- /dev/null +++ b/flake.nix @@ -0,0 +1,22 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in + { + devShells.default = with pkgs; with elmPackages; mkShell { + buildInputs = [ + elm + elm-format + elm-test + elm-review + elm-json + ]; + }; + }); +} diff --git a/review/elm.json b/review/elm.json index 0072270..7cb6cf3 100644 --- a/review/elm.json +++ b/review/elm.json @@ -9,10 +9,11 @@ "elm/core": "1.0.5", "elm/json": "1.1.3", "elm/project-metadata-utils": "1.0.1", - "jfmengels/elm-review": "2.4.1", - "jfmengels/elm-review-performance": "1.0.0", - "jfmengels/elm-review-unused": "1.1.9", - "stil4m/elm-syntax": "7.2.2" + "jfmengels/elm-review": "2.13.1", + "jfmengels/elm-review-simplify": "2.1.3", + "jfmengels/elm-review-unused": "1.2.0", + "jfmengels/elm-review-performance": "1.0.2", + "stil4m/elm-syntax": "7.3.2" }, "indirect": { "elm/html": "1.0.0", @@ -20,15 +21,15 @@ "elm/random": "1.0.0", "elm/time": "1.0.0", "elm/virtual-dom": "1.0.2", - "elm-community/list-extra": "8.3.0", - "elm-explorations/test": "1.2.2", + "elm-community/list-extra": "8.7.0", + "elm-explorations/test": "2.2.0", "rtfeldman/elm-hex": "1.0.0", "stil4m/structured-writer": "1.0.3" } }, "test-dependencies": { "direct": { - "elm-explorations/test": "1.2.2" + "elm-explorations/test": "2.2.0" }, "indirect": {} } diff --git a/review/src/ReviewConfig.elm b/review/src/ReviewConfig.elm index 74dab0d..8ff3c0e 100644 --- a/review/src/ReviewConfig.elm +++ b/review/src/ReviewConfig.elm @@ -21,6 +21,7 @@ import NoUnused.Parameters import NoUnused.Patterns import NoUnused.Variables import Review.Rule exposing (Rule) +import Simplify config : List Rule @@ -38,5 +39,6 @@ config = , NoUnused.Parameters.rule , NoUnused.Patterns.rule , NoUnused.Variables.rule + , Simplify.rule (Simplify.expectNaN Simplify.defaults) , NoUnoptimizedRecursion.rule (NoUnoptimizedRecursion.optOutWithComment "IGNORE TCO") ] diff --git a/src/Obj/Decode.elm b/src/Obj/Decode.elm index 02932ed..c5dc1f9 100644 --- a/src/Obj/Decode.elm +++ b/src/Obj/Decode.elm @@ -1402,7 +1402,7 @@ decodeHelp units decode lines lineno positions normals uvs groups object_ materi [] -> formatError lineno "No material name" - else if startsWith == "" || String.left 1 startsWith == "#" || List.any ((==) startsWith) skipCommands then + else if startsWith == "" || String.left 1 startsWith == "#" || List.member startsWith skipCommands then -- Skip empty lines, comments and unsupported commands decodeHelp units decode remainingLines (lineno + 1) positions normals uvs groups object_ material_ groups_ faceElements lineElements pointsElements diff --git a/src/Obj/Encode.elm b/src/Obj/Encode.elm index d746103..9859ce3 100644 --- a/src/Obj/Encode.elm +++ b/src/Obj/Encode.elm @@ -28,7 +28,6 @@ module Obj.Encode exposing import Array exposing (Array) import Dict exposing (Dict) import Length exposing (Length, Meters) -import Obj.Decode exposing (object) import Point3d exposing (Point3d) import Polyline3d exposing (Polyline3d) import Quantity exposing (Unitless) diff --git a/tests/Encoding.elm b/tests/Encoding.elm index c58a82d..6b98e7e 100644 --- a/tests/Encoding.elm +++ b/tests/Encoding.elm @@ -43,7 +43,7 @@ triangles = \_ -> Encode.encode Length.inMeters (Encode.triangles - (TriangularMesh.indexed (Array.fromList []) [ ( 1, 2, 3 ) ]) + (TriangularMesh.indexed Array.empty [ ( 1, 2, 3 ) ]) ) |> Expect.equal "" , Test.test "skips empty indices" <| @@ -80,7 +80,7 @@ faces = , Test.test "skips empty vertices" <| \_ -> Encode.encode Length.inMeters - (Encode.faces (TriangularMesh.indexed (Array.fromList []) [ ( 1, 2, 3 ) ])) + (Encode.faces (TriangularMesh.indexed Array.empty [ ( 1, 2, 3 ) ])) |> Expect.equal "" , Test.test "skips empty indices" <| \_ -> @@ -124,7 +124,7 @@ texturedTriangles = , Test.test "skips empty vertices" <| \_ -> Encode.encode Length.inMeters - (Encode.texturedTriangles (TriangularMesh.indexed (Array.fromList []) [ ( 1, 2, 3 ) ])) + (Encode.texturedTriangles (TriangularMesh.indexed Array.empty [ ( 1, 2, 3 ) ])) |> Expect.equal "" , Test.test "skips empty indices" <| \_ -> @@ -172,7 +172,7 @@ texturedFaces = , Test.test "skips empty vertices" <| \_ -> Encode.encode Length.inMeters - (Encode.texturedFaces (TriangularMesh.indexed (Array.fromList []) [ ( 1, 2, 3 ) ])) + (Encode.texturedFaces (TriangularMesh.indexed Array.empty [ ( 1, 2, 3 ) ])) |> Expect.equal "" , Test.test "skips empty indices" <| \_ ->