From f6452c36ad0acfee26e1294f6d975136f82438be Mon Sep 17 00:00:00 2001 From: Hauke Ingwersen Date: Wed, 11 Sep 2024 14:51:05 +0200 Subject: [PATCH 1/5] Add github actions --- .github/workflows/ci.yml | 57 ++++++++++++++++++++++++++++++++++++++++ elm-tooling.json | 6 +++++ package.json | 4 ++- 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 elm-tooling.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8223982 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,57 @@ +name: CI + +# CI is run on pull requests and on push to the main branch +on: + pull_request: + push: + branches: [ main ] + +jobs: + test: + # This job is to run the tests + name: Run tests of elm-test + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + node: ['16'] + + env: + ELM_HOME: '${{ github.workspace }}/elm-home' + + steps: + # Clone the repository + - uses: actions/checkout@v2 + + # Setup Node JS + - uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + + # Install elm and cache ELM_HOME + - name: Install elm + uses: mpizenberg/elm-tooling-action@v1.2 + with: + cache-key: tests-${{ matrix.os }}-node${{ matrix.node }}-0 + cache-restore-key: tests-${{ matrix.os }}-node${{ matrix.node }} + + - name: Run the tests + run: npm test:elm + + check_formatting: + # This job is to check the formatting of files + name: Check formatting + runs-on: ubuntu-latest + steps: + # Clone the repository + - uses: actions/checkout@v2 + + # Install elm-format + - name: Install elm-format + uses: mpizenberg/elm-tooling-action@v1.2 + with: + cache-key: format-${{ matrix.os }}-node${{ matrix.node }}-0 + cache-restore-key: format-${{ matrix.os }}-node${{ matrix.node }} + + - name: Check formatting + run: npm run test:format diff --git a/elm-tooling.json b/elm-tooling.json new file mode 100644 index 0000000..87afaf0 --- /dev/null +++ b/elm-tooling.json @@ -0,0 +1,6 @@ +{ + "tools": { + "elm": "0.19.2", + "elm-format": "0.8.7" + } +} diff --git a/package.json b/package.json index 69598e4..9ac9451 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,9 @@ "private": true, "scripts": { "start": "parcel serve --no-cache examples/index.html", - "test": "cypress run", + "test:elm": "elm-test", + "test:format": "elm-format --validate src tests", + "test:cypress": "cypress run", "cypress:open": "cypress open" }, "repository": { From 00c1d6df498622683cfc92660e692c3c199e072b Mon Sep 17 00:00:00 2001 From: Hauke Ingwersen Date: Wed, 11 Sep 2024 15:07:18 +0200 Subject: [PATCH 2/5] Simplyfy workflow, add chache for node modules --- .github/workflows/ci.yml | 54 ++++++++++++++++------------------------ elm-tooling.json | 6 ----- 2 files changed, 22 insertions(+), 38 deletions(-) delete mode 100644 elm-tooling.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8223982..43bdfe1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,15 +9,8 @@ on: jobs: test: # This job is to run the tests - name: Run tests of elm-test - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - node: ['16'] - - env: - ELM_HOME: '${{ github.workspace }}/elm-home' + name: Run tests + runs-on: ubuntu-latest steps: # Clone the repository @@ -26,32 +19,29 @@ jobs: # Setup Node JS - uses: actions/setup-node@v2 with: - node-version: ${{ matrix.node }} + node-version: 16 - # Install elm and cache ELM_HOME - - name: Install elm - uses: mpizenberg/elm-tooling-action@v1.2 + - name: Cache node modules + id: cache-npm + uses: actions/cache@v3 + env: + cache-name: cache-node-modules with: - cache-key: tests-${{ matrix.os }}-node${{ matrix.node }}-0 - cache-restore-key: tests-${{ matrix.os }}-node${{ matrix.node }} + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- - - name: Run the tests - run: npm test:elm - check_formatting: - # This job is to check the formatting of files - name: Check formatting - runs-on: ubuntu-latest - steps: - # Clone the repository - - uses: actions/checkout@v2 - - # Install elm-format - - name: Install elm-format - uses: mpizenberg/elm-tooling-action@v1.2 - with: - cache-key: format-${{ matrix.os }}-node${{ matrix.node }}-0 - cache-restore-key: format-${{ matrix.os }}-node${{ matrix.node }} + # Install elm and cache ELM_HOME + - name: Install dependencies + run: npm install - name: Check formatting - run: npm run test:format + run: npm test:format + + - name: Run the tests + run: npm test:elm diff --git a/elm-tooling.json b/elm-tooling.json deleted file mode 100644 index 87afaf0..0000000 --- a/elm-tooling.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "tools": { - "elm": "0.19.2", - "elm-format": "0.8.7" - } -} From 58e7787f4e7538b13168e47bbe04dcf8cb1f4048 Mon Sep 17 00:00:00 2001 From: Hauke Ingwersen Date: Wed, 11 Sep 2024 15:08:45 +0200 Subject: [PATCH 3/5] Fix npm run command --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 43bdfe1..3e9a059 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: run: npm install - name: Check formatting - run: npm test:format + run: npm run test:format - name: Run the tests - run: npm test:elm + run: npm run test:elm From 2286f8de36afc038a6939028f800775e58c9848d Mon Sep 17 00:00:00 2001 From: Hauke Ingwersen Date: Wed, 11 Sep 2024 15:09:55 +0200 Subject: [PATCH 4/5] Apply format --- src/Task/Extra.elm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Task/Extra.elm b/src/Task/Extra.elm index ff668c3..0008109 100644 --- a/src/Task/Extra.elm +++ b/src/Task/Extra.elm @@ -2,6 +2,7 @@ module Task.Extra exposing (andMap) import Task exposing (Task) + andMap : Task x a -> Task x (a -> b) -> Task x b andMap = Task.map2 (|>) From 2ee299f879c7fc35279f93a2b54c9e1e3c57ab00 Mon Sep 17 00:00:00 2001 From: Hauke Ingwersen Date: Wed, 11 Sep 2024 15:11:49 +0200 Subject: [PATCH 5/5] Fix tests --- tests/AlignmentTest.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/AlignmentTest.elm b/tests/AlignmentTest.elm index 64bac32..75d095c 100644 --- a/tests/AlignmentTest.elm +++ b/tests/AlignmentTest.elm @@ -2,7 +2,7 @@ module AlignmentTest exposing (suite) import Browser.Dom as Dom exposing (Element) import Expect -import Html.Attributes as Attrs +import Html.Styled.Attributes as Attrs import SmartSelect.Alignment as Alignment import Test exposing (Test, describe, test)