Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename + CI #12

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: [gampleman]
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on: [push, pull_request]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: lts/*

# Re-use node_modules between runs until package-lock.json changes.
- name: Cache node_modules
id: internal-cache-node_modules
uses: actions/cache@v3
with:
path: node_modules
key: internal-node_modules-ubuntu-latest.x-${{ hashFiles('package-lock.json') }}

# Re-use ~/.elm between runs until elm.json, elm-tooling.json or
# review/elm.json changes. The Elm compiler saves downloaded Elm packages
# to ~/.elm, and elm-tooling saves downloaded tool executables there.
- name: Cache ~/.elm
uses: actions/cache@v3
with:
path: ~/.elm
key: elm-${{ hashFiles('elm.json', 'review/elm.json') }}

- name: Install npm dependencies
if: steps.cache-node_modules.outputs.cache-hit != 'true'

run: npm ci

- name: Run tests
run: npm test
51 changes: 28 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# elm-review-todo-it-for-me
# elm-review-derive

This elm-review rule is special in that it's not really a rule that checks for mistakes.
Instead it looks for code like this
Expand Down Expand Up @@ -31,49 +31,49 @@ This rule isn't limited to generating toString functions for custom types though

### `Serialize.Codec e MyType`

**Required package:** [MartinSStewart/elm-serialize]
**Type features supported:** All\*
Required package: [MartinSStewart/elm-serialize]
Type features supported: **All\***

### `Csv.Decode.Decoder MyType`

**Required package:** [BrianHicks/elm-csv]
**Type features supported:** Supports (non-recursive) custom types and type aliases as well as most primitives. Doesn't support collection types.
Required package: [BrianHicks/elm-csv]
Type features supported: Supports (non-recursive) **custom types and type aliases** as well as most primitives. Doesn't support collection types.

### `String -> Maybe MyType`

**Required package:** [elm/core]
**Type features supported:** Enums\*\*
Required package: [elm/core]
Type features supported: **Enums\*\***

### `Fuzz.Fuzzer MyType`

**Required package:** [elm-explorations/test]
**Type features supported:** All\*
Required package: [elm-explorations/test]
Type features supported: **All\***

### `Json.Decode.Decoder MyType`

**Required package:** [elm/json]
**Type features supported:** All\*
Required package: [elm/json]
Type features supported: **All\***

### `MyType -> Json.Encode.Value`

**Required package:** [elm/json]
**Type features supported:** All\*
Required package: [elm/json]
Type features supported: **All\***

### `List MyType`

**Required package:** [elm/core]
**Type features supported:** Enums\*\*
Required package: [elm/core]
Type features supported: **Enums\*\***

### `Random.Generator MyType`

**Required package:** [elm/random]
**Type features supported:** All\*
**Optional packages:** [elm-community/random-extra] supported - it will use `Random.Extra.anyInt`, `Random.Extra.choices` and `Random.Extra.andThen` if you have the package installed.
Required package: [elm/random]
Type features supported: **All\***
Optional packages: [elm-community/random-extra] supported - it will use `Random.Extra.anyInt`, `Random.Extra.choices` and `Random.Extra.andThen` if you have the package installed.

### `MyType -> String`

**Required package:** [elm/core]
**Type features supported:** Enums\*\*
Required package: [elm/core]
Type features supported: **Enums\*\***

\* All types actually supported by the relevant packages. Generally this means that it won't support function types, nor opaque
types that don't provide a compatible signature (i.e. a `Decoder { foo : Color }` will fail of `Color` is an opaque type,
Expand Down Expand Up @@ -140,11 +140,15 @@ More formally, for every type variable in the target type, you can provide an ar
You can add it to your review config like any elm-review rule. However, I like to invoke it from the command line when I want it. You can do that with:

```bash
npx elm-review --fix --template MartinSStewart/elm-review-todo-it-for-me/preview
npx elm-review --fix --template gampleman/elm-review-derive/preview
```

If you like it, you can save that command in a convenient shell alias.

```bash
alias elm-derive='npx elm-review --fix --template gampleman/elm-review-derive/preview'
```

## How stable is it? Are there bugs?

It seems to work reasonably well. That said, it is a rather complex piece of code and testing it in anger on large codebases is likely to surface things
Expand Down Expand Up @@ -231,6 +235,7 @@ MIT License

## History

This package was initially concieved and implemented by @MartinSStewart with a slightly different focus (there was some tooling to generate Lamdera migrations for instance) and a more custom architecture.
This package was initially conceived and implemented by @MartinSStewart with a slightly different focus (there was some tooling to generate Lamdera migrations for instance) and a more custom architecture.
It was called MartinSStewart/elm-review-todo-it-for-me.

@gampleman then took the project over with some refactoring work on a more general architecture focused on type-oriented code generation.
@gampleman then took the project over with some refactoring work on a more general architecture focused on type-oriented code generation. He renamed the project to be slightly less unwieldy to pronounce.
1 change: 1 addition & 0 deletions docs.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions e2e/Standard.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module Standard exposing (A(..), B)

import Array exposing (Array)
import Dict exposing (Dict)

Expand Down
7 changes: 4 additions & 3 deletions e2e/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ set -e

SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
cat << EOF > $SCRIPT_DIR/../tests/StandardModule.elm
module StandardModule exposing (..)
module StandardModule exposing (standard)

-- Do not edit this module directly, it is generated from ../e2e/Standard.elm


standard : String
standard =
"""$(cat $SCRIPT_DIR/Standard.elm)"""
Expand All @@ -16,8 +17,8 @@ EOF

cp $SCRIPT_DIR/E2E.elm $SCRIPT_DIR/../tests/E2E.elm
cp $SCRIPT_DIR/Standard.elm $SCRIPT_DIR/../tests/Standard.elm
elm-review --config ./preview --fix-all-without-prompt $SCRIPT_DIR/../tests
npx elm-review --config ./preview --fix-all-without-prompt $SCRIPT_DIR/../tests

elm-test $SCRIPT_DIR/../tests/E2E.elm
npx elm-test $SCRIPT_DIR/../tests/E2E.elm

rm -f $SCRIPT_DIR/../tests/E2E.elm $SCRIPT_DIR/../tests/Standard.elm
2 changes: 1 addition & 1 deletion elm.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "package",
"name": "MartinSStewart/elm-review-todo-it-for-me",
"name": "gampleman/elm-review-derive",
"summary": "Generate code for json encoders/decoders, codecs, fuzzers, generators, and more",
"license": "MIT",
"version": "1.0.0",
Expand Down
Loading
Loading