Skip to content

Commit 0cce9d4

Browse files
authored
Merge pull request #40 from rowtype-yoga/spago-yaml
Migrate to spago@next
2 parents ecdd584 + 66ea855 commit 0cce9d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+12146
-648
lines changed

.github/workflows/ci.yml

+42-20
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,70 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v2
1413
# https://github.com/marketplace/actions/cache-apt-packages
14+
- uses: actions/checkout@v4
1515
- uses: awalsh128/cache-apt-pkgs-action@latest
1616
with:
1717
packages: protobuf-compiler
1818

19+
# https://github.com/purescript-contrib/setup-purescript/
1920
- name: Set up a PureScript toolchain
2021
uses: purescript-contrib/setup-purescript@main
2122
with:
2223
purescript: "unstable"
2324
purs-tidy: "latest"
25+
spago: "unstable"
2426

27+
# https://github.com/marketplace/actions/cache
2528
- name: Cache PureScript dependencies
26-
uses: actions/cache@v2
29+
uses: actions/cache@v4
2730
with:
28-
key: ${{ runner.os }}-spago-${{ hashFiles('**/*.dhall') }}-2
31+
key: ${{ runner.os }}-spago-${{ hashFiles('**/spago.lock') }}-2
2932
path: |
30-
.spago
31-
output
33+
./plugin/.spago
34+
./conformance/.spago
3235
3336
- name: Install dependencies
34-
run: spago install
37+
run: |
38+
protoc --version
39+
echo -n "node "
40+
node --version
41+
echo -n "purs "
42+
purs --version
43+
echo -n "spago "
44+
spago --version
45+
echo ""
46+
spago install
3547
36-
- name: Install plugin dependencies
37-
run: spago -x spago-plugin.dhall install
48+
- name: Build Plugin
49+
run: |
50+
cd plugin
51+
spago build
3852
39-
- name: Install test dependencies
40-
run: spago -x spago-test.dhall install
53+
- name: Test Plugin
54+
# Need --experimental_allow_proto3_optional until the CI protoc is upgraded
55+
run: |
56+
protoc --experimental_allow_proto3_optional --plugin=bin/protoc-gen-purescript --purescript_out=./plugin/test/Test/generated ./plugin/test/*.proto
57+
cd plugin
58+
spago test
4159
42-
- name: Build plugin
43-
run: spago -x spago-plugin.dhall build --no-install --purs-args '--censor-lib --strict --censor-codes='UserDefinedWarning''
60+
# - name: Install test dependencies
61+
# run: spago -x spago-test.dhall install
4462

45-
- run: mkdir -p ./test/generated
63+
# - name: Build plugin
64+
# run: spago -x spago-plugin.dhall build --no-install --purs-args '--censor-lib --strict --censor-codes='UserDefinedWarning''
4665

47-
- name: Generate test from .proto
48-
run: PATH=./bin:$PATH protoc --experimental_allow_proto3_optional --purescript_out=./test/generated test/*.proto
66+
# - run: mkdir -p ./test/generated
4967

50-
- name: Build test
51-
run: spago -x spago-test.dhall build --no-install --purs-args '--censor-lib --censor-codes='UserDefinedWarning''
68+
# - name: Generate test from .proto
69+
# run: PATH=./bin:$PATH protoc --experimental_allow_proto3_optional --purescript_out=./test/generated test/*.proto
5270

53-
- name: Run tests
54-
run: spago -x spago-test.dhall test --no-install
71+
# - name: Build test
72+
# run: spago -x spago-test.dhall build --no-install --purs-args '--censor-lib --censor-codes='UserDefinedWarning''
73+
74+
# - name: Run tests
75+
# run: spago -x spago-test.dhall test --no-install
5576

5677
# We're not running the conformance test because the conformance
57-
# test runner is a pretty heavy build.
78+
# test runner is a pretty heavy build.
79+

.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"purescript.buildCommand": "spago -x spago-dev.dhall build --purs-args --json-errors",
2+
"purescript.buildCommand": "spago build --json-errors",
33
}

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
22

3+
- `spago@next` build system. Reorganized packages.
34

45
# v4.4.0 2024-10-15
56

README.md

+45-22
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ We do not support
3030

3131
### Conformance and Testing
3232

33-
In this version, we pass all 651 of the
33+
In this version, we pass all 684 of the
3434
[Google conformance tests](https://github.com/protocolbuffers/protobuf/tree/main/conformance)
35-
of binary-wire-format *proto3* for [Protocol Buffers v23.2](https://github.com/protocolbuffers/protobuf/releases/).
35+
of binary-wire-format *proto3* for [Protocol Buffers v28.2](https://github.com/protocolbuffers/protobuf/releases/tag/v28.2).
3636
See the `conformance/README.md` in this repository for details.
3737

3838
We also have our own unit tests, see `test/README.md` in this repository.
@@ -50,13 +50,15 @@ The `nix develop` environment provides
5050
$ nix develop
5151
5252
PureScript Protobuf development environment
53-
libprotoc 23.2
54-
purs 0.15.8
55-
node v18.16.0
53+
libprotoc 28.2
54+
node v20.15.1
55+
purs 0.15.15
56+
spago 0.93.40
5657
5758
To build the protoc compiler plugin, run:
5859
59-
spago -x spago-plugin.dhall build
60+
cd plugin
61+
spago build
6062
6163
To compile PureScript .purs files from .proto files, run for example:
6264
@@ -65,19 +67,30 @@ To compile PureScript .purs files from .proto files, run for example:
6567

6668
We can test out code generation immediately by
6769
generating `.purs` files for any of Google’s built-in “well-known types” in the
68-
[`google.protobuf`](https://protobuf.dev/reference/protobuf/google.protobuf/) package namespace. Try the command `protoc --purescript_out=. google/protobuf/any.proto`
69-
or `protoc --purescript_out=. google/protobuf/timestamp.proto`.
70+
[`google.protobuf`](https://protobuf.dev/reference/protobuf/google.protobuf/) package namespace. Try the command
71+
```console
72+
protoc --purescript_out=. google/protobuf/any.proto
73+
```
74+
or
75+
```console
76+
protoc --purescript_out=. google/protobuf/timestamp.proto
77+
```
7078

7179
To see
7280
[all of the `.proto` definitions](https://github.com/protocolbuffers/protobuf/tree/main/src/google/protobuf)
7381
included with the Nix PureScript Protobuf installation including
7482
the “well-known types,”
75-
`ls $(nix path-info .#protobuf)/src/google/protobuf/*.proto`
83+
```console
84+
ls $(nix path-info .#protobuf)/src/google/protobuf/*.proto
85+
```
7686

77-
If you don't want to use Nix, then install the PureScript toolchain and `protoc`,
78-
and add the executable script
79-
[`bin/protoc-gen-purescript`](bin/protoc-gen-purescript)
80-
to your `PATH`.
87+
If you don't want to use Nix,
88+
1. install the PureScript toolchain and `protoc`.
89+
2. Build the [PureScript plugin for `protoc`](plugin/).
90+
3. Run `protoc` with the path to the PureScript plugin executable, like for example
91+
```console
92+
protoc --plugin=bin/protoc-gen-purescript --purescript_out=. google/protobuf/timestamp.proto
93+
```
8194

8295
## Writing programs with the generated code
8396

@@ -245,13 +258,12 @@ programs which use code generated by __protobuf__. Refer to these
245258
for further examples of how to use the generated code.
246259

247260
1. The `protoc`
248-
[compiler plugin](https://github.com/xc-jp/purescript-protobuf/blob/master/plugin/ProtocPlugin/Main.purs).
249-
The code generator imports generated code. Trippy, right? This program
250-
literally writes itself.
261+
[compiler plugin](https://github.com/xc-jp/purescript-protobuf/blob/master/plugin/src/ProtocPlugin/Main.purs).
262+
The code generator imports generated code. This program writes itself.
251263
2. The
252-
[unit test suite](https://github.com/xc-jp/purescript-protobuf/blob/master/test/Main.purs)
264+
[unit test suite](https://github.com/xc-jp/purescript-protobuf/blob/master/library/test/Main.purs)
253265
3. The Google
254-
[conformance test program](https://github.com/xc-jp/purescript-protobuf/blob/master/conformance/Main.purs)
266+
[conformance test program](https://github.com/xc-jp/purescript-protobuf/blob/master/conformance/src/Main.purs)
255267

256268
The [Protobuf Decoder Explainer](http://jamesdbrock.github.io/protobuf-decoder-explainer/) shows an
257269
example of how to use this library to parse binary Protobuf when we don’t
@@ -317,10 +329,11 @@ For that reason, we can only use top-level
317329
### PureScript Imports
318330

319331
The generated PureScript code will usually have module imports which cause
320-
the `purs` compiler to emit redundant import warnings. Sorry. If this causes
332+
the `purs` compiler to emit `ImplicitQualifiedImport` warnings. Sorry. If this causes
321333
trouble then the imports can be fixed automatically in a precompiling pass
322334
with the command-line tool
323335
[__suggest__](https://github.com/nwolverson/purescript-suggest).
336+
Or you can [censor the warnings](https://discourse.purescript.org/t/suppressing-warnings-in-code/2485).
324337

325338
## Nix derivation
326339

@@ -330,9 +343,19 @@ derivation. Include `protoc-gen-purescript` and `protobuf` as `nativeBuildInputs
330343
Then `protoc --purescript_out=path_to_output file.proto` will be runnable
331344
in our derivation phases.
332345

333-
(`protoc-gen-purescript` requires an impure build for the `spago2nix` step,
334-
so you’ll have to grant
335-
trust at the prompt or configure a relaxed Nix sandbox.)
346+
Building `protoc-gen-purescript` requires an impure Nix build environment.
347+
348+
You might need in your `flake.nix`:
349+
350+
```
351+
nixConfig.sandbox = "relaxed";
352+
```
353+
354+
You might need in your `~/.config/nix.conf`:
355+
356+
```
357+
experimental-features = nix-command flakes configurable-impure-env auto-allocate-uids
358+
```
336359

337360
The `flake.nix` provides the Google Protocol Buffers conformance tests
338361
as an `app`. To run the conformance tests right now

bin/conformance-purescript

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env bash
2-
node --input-type=module -e "import {main} from './output/Conformance.Main/index.js'; main();"
2+
node --input-type=module --abort-on-uncaught-exception --trace-sigint --trace-uncaught -e "import {main} from './conformance/output/Main/index.js'; main();"

bin/protoc-gen-purescript

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env bash
2-
node --input-type=module -e "import {main} from './output/ProtocPlugin.Main/index.js'; main();"
2+
node --input-type=module -e "import {main} from './plugin/output/ProtocPlugin.Main/index.js'; main();"

bower.json

-44
This file was deleted.

conformance/README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ From the top directory of this repo,
77
```console
88
nix run .#conformance
99
```
10+
or
11+
```console
12+
cd conformance
13+
spago build
14+
```
15+
```console
16+
conformance_test_runner --enforce_recommended bin/conformance-purescript
17+
```
1018

1119
## About the conformance test runner
1220

@@ -20,8 +28,8 @@ The derivations in `nix/protobuf.nix` will build `protoc` and the
2028
To generate the conformance `.purs` in the dev environment:
2129

2230
```console
23-
protoc --purescript_out=./conformance/generated --proto_path=$(nix path-info .#protobuf)/conformance $(nix path-info .#protobuf)/conformance/conformance.proto
31+
protoc --purescript_out=./conformance/src/generated --proto_path=$(nix path-info .#protobuf)/conformance $(nix path-info .#protobuf)/conformance/conformance.proto
2432
```
2533
```console
26-
protoc --purescript_out=./conformance/generated --proto_path=$(nix path-info .#protobuf)/src $(nix path-info .#protobuf)/src/google/protobuf/test_messages_proto3.proto
34+
protoc --purescript_out=./conformance/src/generated --proto_path=$(nix path-info .#protobuf)/src $(nix path-info .#protobuf)/src/google/protobuf/test_messages_proto3.proto
2735
```

conformance/generated/.gitignore

-1
This file was deleted.

0 commit comments

Comments
 (0)