Skip to content

Commit 8c86cf4

Browse files
authored
Merge pull request #255 from bytecodealliance/ydnar/cm-module
cm: extract package cm into its own distinct module
2 parents 4404cd2 + 272cc7e commit 8c86cf4

File tree

12 files changed

+104
-33
lines changed

12 files changed

+104
-33
lines changed

.github/dependabot.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ updates:
1212
interval: weekly
1313
open-pull-requests-limit: 10
1414

15+
- package-ecosystem: gomod
16+
directory: "/cm"
17+
schedule:
18+
interval: weekly
19+
open-pull-requests-limit: 10
20+
1521
- package-ecosystem: gomod
1622
directory: "/tests"
1723
schedule:

.github/workflows/release.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
tags:
66
- 'v[0-9]+.[0-9]+.*'
77

8+
env:
9+
go-modules: ./... ./cm/...
10+
811
jobs:
912
build:
1013
name: Build binaries
@@ -30,7 +33,7 @@ jobs:
3033
go-version-file: go.mod
3134

3235
- name: Run Go tests
33-
run: go test -v ./...
36+
run: go test ${{ env.go-modules }}
3437

3538
- name: Build binary
3639
run: |

.github/workflows/test.yaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313
- 'LICENSE'
1414

1515
env:
16+
go-modules: ./... ./cm/...
1617
wasm-tools-version: "1.219.1"
1718
wasmtime-version: "26.0.0"
1819

@@ -34,7 +35,7 @@ jobs:
3435
go-version-file: go.mod
3536

3637
- name: Vet Go code
37-
run: go vet ./...
38+
run: go vet ${{ env.go-modules }} ./tests/...
3839

3940
# Test with Go
4041
test-go:
@@ -61,15 +62,15 @@ jobs:
6162
version: ${{ env.wasm-tools-version }}
6263

6364
- name: Run Go tests
64-
run: go test -v ./...
65+
run: go test -v ${{ env.go-modules }}
6566

6667
- name: Run Go tests with race detector
67-
run: go test -v -race ./...
68+
run: go test -v -race ${{ env.go-modules }}
6869

6970
- name: Test Go without cgo
7071
env:
7172
CGO_ENABLED: 0
72-
run: go test -v ./...
73+
run: go test -v ${{ env.go-modules }}
7374

7475
- name: Verify repo is unchanged
7576
run: git diff --exit-code HEAD
@@ -108,7 +109,7 @@ jobs:
108109
version: ${{ env.wasm-tools-version }}
109110

110111
- name: Test with TinyGo
111-
run: tinygo test -v ./...
112+
run: tinygo test -v ${{ env.go-modules }}
112113

113114
- name: Verify repo is unchanged
114115
run: git diff --exit-code HEAD
@@ -164,19 +165,19 @@ jobs:
164165
env:
165166
GOARCH: wasm
166167
GOOS: wasip1
167-
run: go test -v ./...
168+
run: go test -v ${{ env.go-modules }}
168169

169170
- name: Test wasm/wasip1 with TinyGo 0.32.0
170171
if: ${{ matrix.tinygo-version == '0.32.0' }}
171-
run: tinygo test -v -target=wasi ./...
172+
run: tinygo test -v -target=wasi ${{ env.go-modules }}
172173

173174
- name: Test wasm/wasip1 with TinyGo >= 0.33.0
174175
if: ${{ matrix.tinygo-version != '0.32.0' }}
175-
run: tinygo test -v -target=wasip1 ./...
176+
run: tinygo test -v -target=wasip1 ${{ env.go-modules }}
176177

177178
- name: Test wasm/wasip2 with TinyGo >= 0.33.0
178179
if: ${{ matrix.tinygo-version != '0.32.0' }}
179-
run: tinygo test -v -target=wasip2 ./...
180+
run: tinygo test -v -target=wasip2 ${{ env.go-modules }}
180181

181182
- name: Test generated Go with TinyGo >= 0.34.0
182183
if: ${{ matrix.tinygo-version != '0.32.0' && matrix.tinygo-version != '0.33.0' }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.DS_Store
22
/generated
3+
go.work.sum

CHANGELOG.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
44

55
## [Unreleased]
66

7+
### Changed
8+
9+
- Breaking: package [`cm`](https://pkg.go.dev/go.bytecodealliance.org/cm) is now a separate [module](https://go.dev/ref/mod). This change was made in order to minimize the runtime dependencies of programs that depend on package `cm` but not the rest of the packages in this module. To update your code that depends on package `cm`, run `go get -u go.bytecodealliance.org/...`.
10+
711
### Fixed
812

913
- [#264](https://github.com/bytecodealliance/go-modules/issues/264): fix lowering for imported functions that return named `bool` types.
@@ -14,15 +18,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
1418

1519
- `wit-bindgen-go wit` now accepts an `--interface` argument in the form of `monotonic-clock`, `wasi:clocks/monotonic-clock`, or `wasi:clocks/[email protected]`. This filters the serialized WIT to a specific interface and the other interface(s) it references. This can be used to generate focused WIT with a minimal set of dependencies, and can be combined with the `--world` argument to filter serialized WIT to the intersection of a specific world and interface.
1620

17-
### Fixed
18-
19-
- [#240](https://github.com/bytecodealliance/go-modules/issues/240): correctly handle cyclical data structures when generating variant lowering code.
20-
2121
### Changed
2222

2323
- Breaking: package `wit` no longer interprets `-` to read from stdin when loading JSON or WIT using `wit.LoadJSON` or `wit.LoadWIT`. Use `wit.DecodeJSON` or `wit.DecodeWIT` to read JSON or WIT from an `io.Reader`.
2424
- Breaking: `wit.ParseWIT` has been removed. Use `wit.DecodeWIT(bytes.NewReader(b))` instead.
2525

26+
### Fixed
27+
28+
- [#240](https://github.com/bytecodealliance/go-modules/issues/240): correctly handle cyclical data structures when generating variant lowering code.
29+
2630
## [v0.4.0] — 2024-11-05
2731

2832
This module has been renamed. Going forward, please use `go.bytecodealliance.org` instead of `github.com/bytecodealliance/wasm-tools-go`.

RELEASE.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@
22

33
This document describes the steps to release a new version of the `wit-bindgen-go` CLI.
44

5-
## 1. Update [CHANGELOG.md](./CHANGELOG.md)
5+
## 1. Prerequisites
6+
7+
If package `cm` has changed, make the neccessary updates to [cm/CHANGELOG.md](./cm/CHANGELOG.md) and create a new release for `go.bytecodealliance.org/cm`. Then update the dependency in this module by running:
8+
9+
```console
10+
go get -u go.bytecodealliance.org/cm@latest
11+
```
12+
13+
Commit those changes prior to tagging a new release of this module.
14+
15+
## 2. Update [CHANGELOG.md](./CHANGELOG.md)
616

717
1. Add the latest changes to [CHANGELOG.md](./CHANGELOG.md).
818
1. Rename the Unreleased section to reflect the new version number.
919
1. Update the links to new version tag in the footer of CHANGELOG.md
1020
1. Add today’s date (YYYY-MM-DD) after an em dash (—).
1121
1. Submit a [GitHub Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) with these updates.
1222

13-
## 2. Create a new release
23+
## 3. Create a new release
1424

1525
Once the PR is merged, tag the new version in Git and push the tag to GitHub.
1626

cm/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4+
5+
## [Unreleased]
6+
7+
Initial version, extracted into module [`go.bytecodealliance.org/cm`](https://pkg.go.dev/go.bytecodealliance.org/cm).
8+
9+
[Unreleased]: <https://github.com/bytecodealliance/go-modules/compare/cm/v0.1.0..HEAD>
10+
[v0.1.0]: <https://github.com/bytecodealliance/go-modules/tree/cm/v0.1.0>

cm/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# go.bytecodealliance.org/cm
2+
3+
[![pkg.go.dev](https://img.shields.io/badge/docs-pkg.go.dev-blue.svg)](https://pkg.go.dev/go.bytecodealliance.org/cm) [![build status](https://img.shields.io/github/actions/workflow/status/bytecodealliance/go-modules/test.yaml?branch=main)](https://github.com/bytecodealliance/go-modules/actions)
4+
5+
## About
6+
7+
Package `cm` contains helper types and functions used by generated packages, such as `option<t>`, `result<ok, err>`, `variant`, `list`, and `resource`. These are intended for use by generated [Component Model](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#type-definitions) bindings, where the caller converts to a Go equivalent. It attempts to map WIT semantics to their equivalent in Go where possible.
8+
9+
### Note on Memory Safety
10+
11+
Package `cm` and generated bindings from `wit-bindgen-go` may have compatibility issues with the Go garbage collector, as they directly represent `variant` and `result` types as tagged unions where a pointer shape may be occupied by a non-pointer value. The GC may detect and throw an error if it detects a non-pointer value in an area it expects to see a pointer. This is an area of active development.
12+
13+
## License
14+
15+
This project is licensed under the Apache 2.0 license with the LLVM exception. See [LICENSE](../LICENSE) for more details.

cm/RELEASE.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Release
2+
3+
This document describes the steps to release a new version of module `go.bytecodealliance.org/cm`.
4+
5+
## 1. Update [CHANGELOG.md](./CHANGELOG.md)
6+
7+
1. Add the latest changes to [CHANGELOG.md](./CHANGELOG.md).
8+
1. Rename the Unreleased section to reflect the new version number.
9+
1. Update the links to new version tag in the footer of CHANGELOG.md
10+
1. Add today’s date (YYYY-MM-DD) after an em dash (—).
11+
1. Submit a [GitHub Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) with these updates.
12+
13+
## 2. Create a new release
14+
15+
Once the PR is merged, tag the new version in Git and push the tag to GitHub.
16+
17+
**Note:** the tag **must** start with the prefix `cm/` in order to correctly tag this module.
18+
19+
For example, to tag version `cm/v0.2.0`:
20+
21+
```console
22+
git tag cm/v0.2.0
23+
git push origin cm/v0.2.0
24+
```
25+
26+
## 3. Update the root module
27+
28+
Once the tag is pushed, you can update the root module to depend on the newly created version of package `cm` by running the following:
29+
30+
```console
31+
go get -u go.bytecodealliance.org/cm@latest
32+
```
33+
34+
Then follow the instructions in [RELEASE.md](../RELEASE.md) to release a new version of the root module.

cm/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module go.bytecodealliance.org/cm
2+
3+
go 1.22.0

0 commit comments

Comments
 (0)