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

cargo-dist #538

Merged
merged 16 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from 11 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
126 changes: 126 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# CI that:
#
# * checks for a Git Tag that looks like a release
# * creates a Github Release™ and fills in its text
# * builds artifacts with cargo-dist (executable-zips, installers)
# * uploads those artifacts to the Github Release™
#
# Note that the Github Release™ will be created before the artifacts,
# so there will be a few minutes where the release has no artifacts
# and then they will slowly trickle in, possibly failing. To make
# this more pleasant we mark the release as a "draft" until all
# artifacts have been successfully uploaded. This allows you to
# choose what to do with partial successes and avoids spamming
# anyone with notifications before the release is actually ready.
name: Release

permissions:
contents: write

# This task will run whenever you push a git tag that looks like a version
# like "v1", "v1.2.0", "v0.1.0-prerelease01", "my-app-v1.0.0", etc.
# The version will be roughly parsed as ({PACKAGE_NAME}-)?v{VERSION}, where
# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION
# must be a Cargo-style SemVer Version.
#
# If PACKAGE_NAME is specified, then we will create a Github Release™ for that
# package (erroring out if it doesn't have the given version or isn't cargo-dist-able).
#
# If PACKAGE_NAME isn't specified, then we will create a Github Release™ for all
# (cargo-dist-able) packages in the workspace with that version (this is mode is
# intended for workspaces with only one dist-able package, or with all dist-able
# packages versioned/released in lockstep).
#
# If you push multiple tags at once, separate instances of this workflow will
# spin up, creating an independent Github Release™ for each one.
#
# If there's a prerelease-style suffix to the version then the Github Release™
# will be marked as a prerelease.
on:
push:
tags:
- '*-?v[0-9]+*'

jobs:
# Create the Github Release™ so the packages have something to be uploaded to
create-release:
runs-on: ubuntu-latest
outputs:
has-releases: ${{ steps.create-release.outputs.has-releases }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Install Rust
run: rustup update 1.67.1 --no-self-update && rustup default 1.67.1
- name: Install cargo-dist
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.sh | sh
- id: create-release
run: |
cargo dist plan --tag=${{ github.ref_name }} --output-format=json > dist-manifest.json
echo "dist plan ran successfully"
cat dist-manifest.json

# Create the Github Release™ based on what cargo-dist thinks it should be
ANNOUNCEMENT_TITLE=$(jq --raw-output ".announcement_title" dist-manifest.json)
IS_PRERELEASE=$(jq --raw-output ".announcement_is_prerelease" dist-manifest.json)
jq --raw-output ".announcement_github_body" dist-manifest.json > new_dist_announcement.md
gh release create ${{ github.ref_name }} --draft --prerelease="$IS_PRERELEASE" --title="$ANNOUNCEMENT_TITLE" --notes-file=new_dist_announcement.md
echo "created announcement!"

# Upload the manifest to the Github Release™
gh release upload ${{ github.ref_name }} dist-manifest.json
echo "uploaded manifest!"

# Disable all the upload-artifacts tasks if we have no actual releases
HAS_RELEASES=$(jq --raw-output ".releases != null" dist-manifest.json)
echo "has-releases=$HAS_RELEASES" >> "$GITHUB_OUTPUT"

# Build and packages all the things
upload-artifacts:
# Let the initial task tell us to not run (currently very blunt)
needs: create-release
if: ${{ needs.create-release.outputs.has-releases == 'true' }}
strategy:
matrix:
# For these target platforms
include:
- os: ubuntu-20.04
dist-args: --artifacts=global
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.sh | sh
- os: macos-11
dist-args: --artifacts=local --target=aarch64-apple-darwin --target=x86_64-apple-darwin
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.sh | sh
- os: ubuntu-20.04
dist-args: --artifacts=local --target=x86_64-unknown-linux-gnu
install-dist: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.sh | sh
- os: windows-2019
dist-args: --artifacts=local --target=x86_64-pc-windows-msvc
install-dist: irm https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.ps1 | iex

runs-on: ${{ matrix.os }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Install Rust
run: rustup update 1.67.1 --no-self-update && rustup default 1.67.1
- name: Install cargo-dist
run: ${{ matrix.install-dist }}
- name: Run cargo-dist
# This logic is a bit janky because it's trying to be a polyglot between
# powershell and bash since this will run on windows, macos, and linux!
# The two platforms don't agree on how to talk about env vars but they
# do agree on 'cat' and '$()' so we use that to marshal values between commands.
run: |
# Actually do builds and make zips and whatnot
cargo dist build --tag=${{ github.ref_name }} --output-format=json ${{ matrix.dist-args }} > dist-manifest.json
echo "dist ran successfully"
cat dist-manifest.json

# Parse out what we just built and upload it to the Github Release™
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json > uploads.txt
echo "uploading..."
cat uploads.txt
gh release upload ${{ github.ref_name }} $(cat uploads.txt)
echo "uploaded!"
62 changes: 22 additions & 40 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

All notable changes to this project will be documented in this file.

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).
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
and [`cargo-dist`'s expected
format](https://opensource.axo.dev/cargo-dist/book/simple-guide.html#release-notes),
and this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0.html).

<!----------------------------------------------------------------------
The "Unreleased" section should be amended as major changes are merged
Expand Down Expand Up @@ -44,37 +47,23 @@ This name should be decided amongst the team before the release.
* [#533](https://github.com/tweag/topiary/pull/533) Update tree-sitter-ocaml to 0.20.3
* [#535](https://github.com/tweag/topiary/pull/535) Improved error message when idempotency fails due to invalid output in the first pass.

## [0.2.3] - 2023-06-20
torhovland marked this conversation as resolved.
Show resolved Hide resolved
## v0.2.3 - Cyclic Cypress
[0.2.2]: https://github.com/tweag/topiary/compare/v0.2.2...v0.2.3
torhovland marked this conversation as resolved.
Show resolved Hide resolved

### Added
* [#513](https://github.com/tweag/topiary/pull/513) Added the `-t, --tolerate-
parsing-errors` flags to Topiary, `tolerate_parsing_errors` to the `Format`
operation of the library, and a "Tolerate parsing errors" checkmark to the
playground. These options make Topiary ignore errors in the parsed file, and
attempt to format it.
* [#506](https://github.com/tweag/topiary/pull/506) Allows the users to
configure Topiary through a user-defined configuration file. More information
can be found in the `README.md`.
* [#513](https://github.com/tweag/topiary/pull/513) Added the `-t, --tolerate-parsing-errors` flags to Topiary, `tolerate_parsing_errors` to the `Format` operation of the library, and a "Tolerate parsing errors" checkmark to the playground. These options make Topiary ignore errors in the parsed file, and attempt to format it.
* [#506](https://github.com/tweag/topiary/pull/506) Allows the users to configure Topiary through a user-defined configuration file. More information can be found in the `README.md`.

### Changed
* [#523](https://github.com/tweag/topiary/pull/523) Skips rebuilding the tree-
sitter `Query` when performing the idempotence check. This improves performance
when not skipping the idempotence check by about `35%` for OCaml formatting.
* [#523](https://github.com/tweag/topiary/pull/523) Skips rebuilding the tree-sitter `Query` when performing the idempotence check. This improves performance when not skipping the idempotence check by about `35%` for OCaml formatting.

### Removed
* [#508](https://github.com/tweag/topiary/pull/508) Simplified language
detection by treating `ocaml` and `ocaml_interface` as two distinct languages.
This ensures we only have one grammar per language. This
removed the `-l ocaml_implementation` flag from Topiary and the
`SupportedLanguage::OcamlImplementation` from the library.
* [#508](https://github.com/tweag/topiary/pull/508) Simplified language detection by treating `ocaml` and `ocaml_interface` as two distinct languages. This ensures we only have one grammar per language. This removed the `-l ocaml_implementation` flag from Topiary and the `SupportedLanguage::OcamlImplementation` from the library.

### Fixed
* [#522](https://github.com/tweag/topiary/pull/522) Reverted the bump to the
OCaml grammar and queries. This bump (for as of yet unknown reasons) had a
catastrophic impact on Topiary's performance.
* [#522](https://github.com/tweag/topiary/pull/522) Reverted the bump to the OCaml grammar and queries. This bump (for as of yet unknown reasons) had a catastrophic impact on Topiary's performance.

## [0.2.2] - 2023-06-12
## v0.2.2 - Cyclic Cypress
[0.2.1]: https://github.com/tweag/topiary/compare/v0.2.1...v0.2.2

### Added
Expand All @@ -89,23 +78,20 @@ This name should be decided amongst the team before the release.
* [#494](https://github.com/tweag/topiary/pull/494) Bumped the OCaml grammar, and fixed for the renamed `infix_operator` named node.

### Fixed
* [#493](https://github.com/tweag/topiary/pull/493) Fixed
[#492](https://github.com/tweag/topiary/issues/492) by only trimming newlines in prettyprinting.
* [#491](https://github.com/tweag/topiary/pull/493) Fixed
[#481](https://github.com/tweag/topiary/issues/492), a SIGSEGV in exhaustivity testing.
* [#493](https://github.com/tweag/topiary/pull/493) Fixed [#492](https://github.com/tweag/topiary/issues/492) by only trimming newlines in prettyprinting.
* [#491](https://github.com/tweag/topiary/pull/493) Fixed [#481](https://github.com/tweag/topiary/issues/492), a SIGSEGV in exhaustivity testing.

## [0.2.1] - 2023-05-23
## v0.2.1 - Cyclic Cypress
[0.2.1]: https://github.com/tweag/topiary/compare/v0.2.0...v0.2.1

### Fixed
* Correctly bumped version number in `Cargo.toml`.

## [0.2.0]: Cyclic Cypress - 2023-05-22
## v0.2.0 - Cyclic Cypress
[0.2.0]: https://github.com/tweag/topiary/compare/v0.1.0...v0.2.0

### Added
* Topiary [website](https://topiary.tweag.io), web-based
[playground](https://topiary.tweag.io/playground) and logos.
* Topiary [website](https://topiary.tweag.io), web-based [playground](https://topiary.tweag.io/playground) and logos.
* Full Nickel formatting support.
* Improved OCaml formatting support.
* `@append_antispace` and `@prepend_antispace` formatting capture names.
Expand All @@ -115,10 +101,8 @@ This name should be decided amongst the team before the release.
* Maintain a CHANGELOG and a documented release process.

### Changed
* Move to a build configuration file, rather than a mixture of
hardcoding and parsing query predicates at runtime.
* Conditional predicates, in the query language, to reduce the number of
formatting capture names.
* Move to a build configuration file, rather than a mixture of hardcoding and parsing query predicates at runtime.
* Conditional predicates, in the query language, to reduce the number of formatting capture names.
* Higher fidelity exit codes.
* Idempotency check in terminal-based playground.
* Reduced verbosity of failed integration test output.
Expand All @@ -132,7 +116,7 @@ This name should be decided amongst the team before the release.
* Don't process queries that match below leaf nodes.
* Skip over zero-byte matched nodes.

## [0.1.0]: Benevolent Beech - 2023-03-09
## v0.1.0 - Benevolent Beech
[0.1.0]: https://github.com/tweag/topiary/compare/v0.0.1-prototype...v0.1.0

This first public release focuses on the Topiary engine and providing
Expand Down Expand Up @@ -169,9 +153,7 @@ required to do so.
* Basic formatter authoring tools (terminal-based playground and tree visualisation)
* `pre-commit-hooks.nix` support

## [0.0.1-prototype]: Archetypal Aspen - 2022-06-14
## v0.0.1-prototype - Archetypal Aspen
[0.0.1-prototype]: https://github.com/tweag/topiary/releases/tag/v0.0.1-prototype

This prototype release was created exclusively to show the validity of
the idea of using Tree-sitter to build a formatter. It includes only a
prototype JSON formatter.
This prototype release was created exclusively to show the validity of the idea of using Tree-sitter to build a formatter. It includes only a prototype JSON formatter.
18 changes: 18 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ exclude = ["samples"]
lto = true
opt-level = 's'

# The profile that 'cargo dist' will build with
[profile.dist]
inherits = "release"
lto = "thin"

# Config for 'cargo dist'
[workspace.metadata.dist]
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
cargo-dist-version = "0.0.7"
# The preferred Rust toolchain to use in CI (rustup toolchain syntax)
rust-toolchain-version = "1.67.1"
# CI backends to support (see 'cargo dist generate-ci')
ci = ["github"]
# The installers to generate for each app
installers = ["shell", "powershell"]
# Target platforms to build apps for (Rust target-triple syntax)
targets = ["x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "aarch64-apple-darwin"]
torhovland marked this conversation as resolved.
Show resolved Hide resolved

[workspace.dependencies]
assert_cmd = "2.0"
cfg-if = "1.0.0"
Expand Down
26 changes: 17 additions & 9 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
* Retitle the "Unreleased" section to this release and create a fresh
"Unreleased" section (see comments in the [CHANGELOG] for details).

Do not wrap bullet points in multiple lines. GitHub will use those line
breaks in the Release Notes display.

:bulb: Point releases (i.e., not patch releases) should also be
given a name, taking the form `ADJECTIVE TREE`, incrementing
alphabetically. This name should be decided amongst the team before
Expand All @@ -21,15 +24,20 @@
* Commit and merge (squash, if necessary) on green CI and peer
approval.

* Tag the merged commit with the release version, prefixed with a `v`
(e.g., `v1.0.0`).
* Tag the merged commit with the release version, prefixed with a `v` (e.g.,
`v0.1.0`). The version number must match the one in `Cargo.toml`, otherwise
`cargo dist` will fail during CI.

```bash
git tag "v0.1.0"
git push
git push --tags
```

* [Draft a new release][draft-release] in GitHub.
* Set the tag to that created in the previous step, now on `main`.
* Set the release title to `Topiary v<RELEASE>`, or `Topiary
* Let `cargo dist` create a new [draft release][releases].
* Update the release title to `Topiary v<RELEASE>`, or `Topiary
v<RELEASE>: <NAME>` for point releases.
* Copy-and-paste the [CHANGELOG] contents for this release
into the description.
* Verify the [CHANGELOG] contents.
* Publish.

* Publicise.
Expand Down Expand Up @@ -68,6 +76,6 @@ fetch, overriding the low default. As of writing, there's no way to set
this to "unlimited"; adjust as necessary.

<!-- Links -->
[changelog]: /changelog.md
[changelog]: /CHANGELOG.md
[changelog-refresh]: #generating-the-pr-list-for-the-changelog
[draft-release]: https://github.com/tweag/topiary/releases/new
[releases]: https://github.com/tweag/topiary/releases