Skip to content

Commit

Permalink
Fix release check script to check new version specs (#6592)
Browse files Browse the repository at this point in the history
## Description

Refactor `verify_tag.sh` to check all the places where lockstep versions
are present in new workspace configuration.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

Co-authored-by: Joshua Batty <[email protected]>
  • Loading branch information
IGI-111 and JoshuaBatty authored Sep 30, 2024
1 parent 6ba98da commit c5f363b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ jobs:
- name: Verify tag version
run: |
cargo install toml-cli
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} Cargo.toml
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }}
- name: Notify if Job Fails
uses: ravsamhq/notify-slack-action@v2
Expand Down
72 changes: 54 additions & 18 deletions .github/workflows/scripts/verify_tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,66 @@ err() {
}

status() {
WIDTH=12
printf "\e[32m\e[1m%${WIDTH}s\e[0m %s\n" "$1" "$2"
local width=12
printf "\e[32m\e[1m%${width}s\e[0m %s\n" "$1" "$2"
}

get_toml_version () {
local toml_path="$1"

local manifest="Cargo.toml"
echo $(toml get $manifest $toml_path | tr -d '"')
}

check_version () {
local ref=$1
local toml_path=$2

# strip preceeding 'v' if it exists on tag
ref=${ref/#v}

local toml_version=$(get_toml_version "$toml_path")

if [ "$toml_version" != "$ref" ]; then
err "Crate version $toml_version for $toml_path, doesn't match tag version $ref"
exit 1
else
status "Crate version for $toml_path matches tag $toml_version"
fi
}

REF=$1
MANIFEST=$2

if [ -z "$REF" ]; then
err "Expected ref to be set"
exit 1
fi

if [ -z "$MANIFEST" ]; then
err "Expected manifest to be set"
exit 1
fi

# strip preceeding 'v' if it exists on tag
REF=${REF/#v}
TOML_VERSION=$(toml get $MANIFEST workspace.package.version | tr -d '"')

if [ "$TOML_VERSION" != "$REF" ]; then
err "Crate version $TOML_VERSION, doesn't match tag version $REF"
exit 1
else
status "Crate version matches tag $TOML_VERSION"
fi
for toml_path in \
"workspace.package.version" \
"workspace.dependencies.forc.version" \
"workspace.dependencies.forc-pkg.version" \
"workspace.dependencies.forc-test.version" \
"workspace.dependencies.forc-tracing.version" \
"workspace.dependencies.forc-util.version" \
"workspace.dependencies.forc-plugins.version" \
"workspace.dependencies.forc-client.version" \
"workspace.dependencies.forc-crypto.version" \
"workspace.dependencies.forc-debug.version" \
"workspace.dependencies.forc-doc.version" \
"workspace.dependencies.forc-fmt.version" \
"workspace.dependencies.forc-lsp.version" \
"workspace.dependencies.forc-tx.version" \
"workspace.dependencies.sway-ast.version" \
"workspace.dependencies.sway-core.version" \
"workspace.dependencies.sway-error.version" \
"workspace.dependencies.sway-lsp.version" \
"workspace.dependencies.sway-parse.version" \
"workspace.dependencies.sway-types.version" \
"workspace.dependencies.sway-utils.version" \
"workspace.dependencies.swayfmt.version" \
"workspace.dependencies.sway-ir.version" \
"workspace.dependencies.sway-ir-macros.version" \
; do
check_version $REF $toml_path
done

0 comments on commit c5f363b

Please sign in to comment.