Skip to content
Open
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
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[resolver]
incompatible-rust-versions = "fallback"
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,32 @@ jobs:
- name: Check formatting
run: pnpm format:check

- name: Check the Rust crate's copies of TypeScript data
run: |
diff -r packages/theme-check-node/configs crates/theme-check/src/node/configs
node -e "console.log(JSON.stringify(require('./packages/theme-check-common').allChecks.map((c) => c.meta)))" \
| diff - crates/theme-check/src/node/checks-meta.json

rust:
runs-on: ubuntu-latest
name: Rust
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Check formatting
run: cargo fmt --all --check

- name: Run the unit tests and the specs
run: cargo test --workspace --locked

- name: Check that the crates package and build on their own
run: cargo publish --dry-run --workspace --locked

- name: Check that the crates have the version of crates/theme-check/package.json
run: |
cargo metadata --no-deps --format-version 1 \
| jq -e --arg version "$(jq -r .version crates/theme-check/package.json)" 'all(.packages[]; .version == $version)'

e2e:
runs-on: ubuntu-latest
name: E2E tests
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ env:
jobs:
publish-packages:
runs-on: ubuntu-latest
outputs:
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}
permissions:
contents: write
pull-requests: write
Expand Down Expand Up @@ -93,3 +95,54 @@ jobs:
run: pnpm publish:ovsx
env:
OVSX_PAT: ${{ secrets.OPENVSX_TOKEN }}

# Its own job, so no npm package runs where a crates.io token can be had.
publish-crates:
needs: publish-packages
if: needs.publish-packages.outputs.hasChangesets == 'false'
runs-on: ubuntu-latest
environment: crates-io
permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

# Until theme-check is on crates.io, published once by hand with a trusted publisher for
# this workflow and environment, this publishes nothing. After a partial publish, the next
# run does the rest.
- name: List the crates whose version isn't on crates.io
id: crates
run: |
version=$(jq -r .version crates/theme-check/package.json)
on_crates_io() {
code=$(curl -s --retry 3 -o /dev/null -w '%{http_code}' -A 'Shopify/theme-tools release' "https://crates.io/api/v1/crates/$1")
case $code in
200) return 0 ;;
404) return 1 ;;
*) echo "::error::crates.io answered $code for $1"; exit 1 ;;
esac
}
list=
if on_crates_io theme-check; then
for crate in liquid-ast liquid-parser theme-check; do
on_crates_io "$crate/$version" || list="$list $crate"
done
fi
echo "list=$list" >> $GITHUB_OUTPUT

- name: Exchange the Actions identity token for a crates.io token
id: crates-io-auth
if: steps.crates.outputs.list != ''
uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5

# In dependency order.
- name: Publish the crates to crates.io
if: steps.crates.outputs.list != ''
run: for crate in $CRATES; do cargo publish -p "$crate" --locked; done
env:
CRATES: ${{ steps.crates.outputs.list }}
CARGO_REGISTRY_TOKEN: ${{ steps.crates-io-auth.outputs.token }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ TODO
tsconfig.builinfo
tsconfig.tsbuildinfo
pnpm-debug.log*
/target
package-lock.json
.npmrc
packages/theme-check-docs-updater/data
Expand Down
218 changes: 218 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[workspace]
resolver = "2"
members = ["crates/liquid-ast", "crates/liquid-parser", "crates/theme-check"]

# The release sets the version from crates/theme-check/package.json, which changesets bumps.
[workspace.package]
version = "0.1.0"
edition = "2021"
rust-version = "1.84"
license = "MIT"
repository = "https://github.com/Shopify/theme-tools"

[workspace.dependencies]
liquid-ast = { path = "crates/liquid-ast", version = "0.1.0" }
liquid-parser = { path = "crates/liquid-parser", version = "0.1.0" }

[profile.release]
lto = "fat"
codegen-units = 1
panic = "abort"
debug = 1
8 changes: 8 additions & 0 deletions crates/liquid-ast/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "liquid-ast"
description = "The syntax tree of Liquid HTML templates, as @shopify/liquid-html-parser builds it"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true
Loading
Loading