Skip to content

Commit

Permalink
Weekly CI pre-release check (#818)
Browse files Browse the repository at this point in the history
* Create scripts

* Fix script

* Run scripts in CI and fix publish = false

Signed-off-by: Filippo Costa <[email protected]>

* Fix release notes

Signed-off-by: Filippo Costa <[email protected]>

---------

Signed-off-by: Filippo Costa <[email protected]>
  • Loading branch information
neysofu authored Sep 15, 2023
1 parent ae50474 commit c2206ff
Show file tree
Hide file tree
Showing 17 changed files with 162 additions and 82 deletions.
41 changes: 0 additions & 41 deletions .github/workflows/cleanup_caches.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/prerelease_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Pre-release checks"
on:
schedule:
# At 10:00am UTC every Monday.
# See:
# - https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
# - https://crontab.guru/
- cron: "0 10 * * 1"
# Allow manual triggering: <https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch>.
workflow_dispatch:
# Anytime a PR modifies the list of packages to publish.
pull_request:
paths:
- "packages_to_publish.yml"

jobs:
check-missing-dependency-versions:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- run: ./scripts/check_missing_dependency_versions.sh
shell: bash
working-directory: .
7 changes: 7 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,10 @@ jobs:
# Exit status 0 means no changes were made, so the table of contents is
# up to date.
run: git diff --exit-code
validate-packages-to-publish-yml:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: ./scripts/validate_packages_to_publish_yml.sh
shell: bash
working-directory: .
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ coverage-html: ## Coverage in HTML format
cargo llvm-cov --locked --all-features --html

dry-run-publish:
cat packages_to_publish.txt | xargs -I _ cargo publish --allow-dirty --dry-run -p _
yq '.[]' packages_to_publish.yml | xargs -I _ cargo publish --allow-dirty --dry-run -p _

docs: ## Generates documentation locally
cargo doc --open
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
<a href="https://github.com/Sovereign-Labs/sovereign-sdk/blob/stable/LICENSE">
<img alt="License: Apache-2.0" src="https://img.shields.io/github/license/Sovereign-Labs/sovereign-sdk.svg" />
</a>
<a href="https://codecov.io/gh/Sovereign-Labs/sovereign-sdk" >
<img alt="Coverage" src="https://codecov.io/gh/Sovereign-Labs/sovereign-sdk/branch/stable/graph/badge.svg"/>
</a>
<a href="https://discord.gg/kbykCcPrcA" >
<a href="https://discord.gg/kbykCcPrcA" >
<img alt="Discord" src="https://img.shields.io/discord/1050059327626555462?label=discord"/>
</a>
<a href="https://codecov.io/gh/Sovereign-Labs/sovereign-sdk" >
<img alt="Coverage" src="https://codecov.io/gh/Sovereign-Labs/sovereign-sdk/branch/nightly/graph/badge.svg"/>
</a>
<img alt="GitHub Workflow Status (with event)" src="https://img.shields.io/github/actions/workflow/status/sovereign-labs/sovereign-sdk/prerelease_checks.yml?label=Pre-release%20checks">
</div>

## What is the Sovereign SDK?
Expand Down
23 changes: 12 additions & 11 deletions Releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ This document describes how to cut a release of the Sovereign SDK.
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Before starting](#before-starting)
- [Pick a version number](#pick-a-version-number)
- [Make sure the documentation and tutorials are up to date](#make-sure-the-documentation-and-tutorials-are-up-to-date)
- [Update all crate versions](#update-all-crate-versions)
- [Prepare the PR](#prepare-the-pr)
- [Release to `crates.io`](#release-to-cratesio)
- [Create a tag and a GitHub release](#create-a-tag-and-a-github-release)
- [Merge to `nightly` and `stable`](#merge-to-nightly-and-stable)
- [Releases](#releases)
- [Before starting](#before-starting)
- [Pick a version number](#pick-a-version-number)
- [Make sure the documentation and tutorials are up to date](#make-sure-the-documentation-and-tutorials-are-up-to-date)
- [Update all crate versions](#update-all-crate-versions)
- [Prepare the PR](#prepare-the-pr)
- [Release to `crates.io`](#release-to-cratesio)
- [Create a tag and a GitHub release](#create-a-tag-and-a-github-release)
- [Merge to `nightly` and `stable`](#merge-to-nightly-and-stable)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand All @@ -38,7 +39,7 @@ Before starting, ensure your local copy of the repository is up to date with the
- [ ] `examples/demo-simple-stf/README.md`
- [ ] `examples/demo-stf/README.md`
- [ ] `examples/demo-nft-module/README.md`
- [ ] Audit `packages_to_publish.txt` and ensure that all relevant _library_ crates are included. Binaries (such as `demo-rollup`) and other internal crates not intended to be used by SDK users (such as `sov-modules-schemas`) should not be included. The list must remain pre-sorted by dependencies, so that crates are published in the correct order.
- [ ] Audit `packages_to_publish.yml` and ensure that all relevant _library_ crates are included. Binaries (such as `demo-rollup`) and other internal crates not intended to be used by SDK users (such as `sov-modules-schemas`) should not be included. The list must remain pre-sorted by dependencies, so that crates are published in the correct order.
- [ ] Commit any changes.

## Update all crate versions
Expand Down Expand Up @@ -71,7 +72,7 @@ After committing these changes, you should open a new PR **against `nightly`**.

## Release to `crates.io`

**After** the PR is approved but **before** it's merged, you should release the crates in `packages_to_publish.txt` to <https://crates.io>. Go through the list of crates to release _in order_ and run these commands:
**After** the PR is approved but **before** it's merged, you should release the crates in `packages_to_publish.yml` to <https://crates.io>. Go through the list of crates to release _in order_ and run these commands:

- [ ] `$ cargo publish --dry-run -p {crate}` to ensure there are no issues.
- [ ] `$ cargo publish -p {crate}` to actually release the crate.
Expand All @@ -85,4 +86,4 @@ After committing these changes, you should open a new PR **against `nightly`**.
## Merge to `nightly` and `stable`

- [ ] Merge your PR to `nightly`.
- [ ] Merge `nightly` to `stable` with a new PR. Make sure no commits that are not part of the release get merged accidentally into `stable`.
- [ ] Merge `nightly` to `stable` with a new PR (example [here](https://github.com/Sovereign-Labs/sovereign-sdk/pull/866#pullrequestreview-1627315759)). Make sure no commits that are not part of the release get merged accidentally into `stable`.
1 change: 1 addition & 0 deletions adapters/celestia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "sov-celestia-adapter"
version = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
1 change: 1 addition & 0 deletions full-node/sov-ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ rust-version = { workspace = true }
version = { workspace = true }
readme = "README.md"
resolver = "2"
publish = false

[dependencies]
anyhow = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions full-node/sov-stf-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ rust-version = { workspace = true }
version = { workspace = true }
readme = "README.md"
resolver = "2"
publish = false

[dependencies]
anyhow = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ rust-version = { workspace = true }
version = { workspace = true }
readme = "README.md"
resolver = "2"
publish = false

[dev-dependencies]
sov-rollup-interface = { path = "../../../rollup-interface", version = "0.2", features = ["mocks"] }
Expand Down
3 changes: 1 addition & 2 deletions module-system/module-implementations/sov-evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ rust-version = { workspace = true }
version = { workspace = true }
readme = "README.md"
resolver = "2"

publish = false

[dependencies]

Expand Down Expand Up @@ -57,4 +57,3 @@ default = []
native = ["serde", "serde_json", "jsonrpsee", "schemars", "clap", "sov-state/native", "sov-modules-api/native"]
experimental = ["native"]
smart_contracts = ["experimental"]

1 change: 1 addition & 0 deletions module-system/module-schemas/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ rust-version = { workspace = true }
version = { workspace = true }
readme = "README.md"
resolver = "2"
publish = false

[build-dependencies]
sov-modules-api = { path = "../sov-modules-api" }
Expand Down
1 change: 1 addition & 0 deletions module-system/utils/sov-data-generators/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ rust-version = { workspace = true }
version = { workspace = true }
readme = "README.md"
resolver = "2"
publish = false


[dependencies]
Expand Down
23 changes: 0 additions & 23 deletions packages_to_publish.txt

This file was deleted.

23 changes: 23 additions & 0 deletions packages_to_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
- sov-rollup-interface
- sov-first-read-last-write-cache
- sov-schema-db
- sov-db
- sov-sequencer
- sov-zk-cycle-macros
- sov-zk-cycle-utils
- sov-state
- sov-modules-macros
- sov-modules-api
- sov-modules-stf-template

# Modules
- sov-accounts
- sov-bank
- sov-sequencer-registry
- sov-prover-incentives
- sov-chain-state
- sov-blob-storage

# Adapters
- sov-risc0-adapter
# TODO: sov-celestia-adapter (https://github.com/Sovereign-Labs/nmt-rs/issues/17)
27 changes: 27 additions & 0 deletions scripts/check_missing_dependency_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

# `cargo-publish` requires all dependencies to have a version specified (e.g. it
# can't be sourced from `git` of `path` alone). This script checks that all
# packages we intend to publish have a version specified in their `Cargo.toml` for all
# dependencies.

set -Euo pipefail

yq '.[]' packages_to_publish.yml | while read -r pkg; do
echo "Checking crate $pkg..."

output=$(cargo publish --allow-dirty --dry-run -p "$pkg")

# Check if the output contains the error message we're looking for.
#
# `cargo publish` may fail for many other reasons, but it'd be too
# hard to reason about them all. This is the only one we can expect
# to catch reliably.
echo "$output" | grep -q "all dependencies must have a version specified when publishing."
if [ $? -eq 0 ]; then
echo "Error: Found problematic output for crate $pkg."
exit 1
fi
done

echo "All crates processed successfully."
57 changes: 57 additions & 0 deletions scripts/validate_packages_to_publish_yml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env bash

set -Euo pipefail

# This script makes sure that all workspace crates that are marked as releasable
# are also listed in packages_to_publish.yml. In addition, it makes sure that
# all packages listed in packages_to_publish.yml have all basic crate metadata and don't
# generate warnings when packaged.
#
# Important: this script is assumed to be cheap to run by our GH Actions
# workflows. Create another script if you need to add checks that are more expensive.

# Somewhat unintuitively, `cargo metadata` returns `"publish": null` for publishable packages.
# From the docs at https://doc.rust-lang.org/cargo/commands/cargo-metadata.html#output-format:
# /* List of registries to which this package may be published.
# Publishing is unrestricted if null, and forbidden if an empty array. */
releasable_packages=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.publish == null) | .name')

echo "Releasable packages according to cargo-metadata:"
echo "$releasable_packages" | sed 's/^/- /'
echo ""

echo "Releasable packages according to packages_to_publish.yml:"
yq '.[]' packages_to_publish.yml | sed 's/^/- /'
echo ""

echo "Validating packages_to_publish.yml..."

status=0
while read -r pkg; do
if yq -e "[\"$pkg\"] - . | length == 1" packages_to_publish.yml > /dev/null 2>&1; then
printf "%40s | ERR is releasable but NOT found in packages_to_publish.yml\n" "$pkg"
status=1
fi
done <<< "$releasable_packages"

echo ""
echo "Validating the present of package metadata for all packages_to_publish.yml entries..."

while read -r pkg; do
# Capture both stdour and stderr.
output=$(cargo package --allow-dirty -p $pkg --list 2>&1)
if echo "$output" | grep -q "warning:"; then
printf "%40s | ERR warnings found:\n" "$pkg"
echo "$output" | grep "warning:"
status=1
fi
done < <(yq '.[]' packages_to_publish.yml)

echo ""
if [ $status -eq 1 ]; then
echo "Validation failed."
exit 1
fi

echo "Validation successful, everything okay."
echo "Goodbye!"

0 comments on commit c2206ff

Please sign in to comment.