Skip to content

Commit db5741c

Browse files
chore: add linter for new crates required crates.io fields (#4428)
## What ❔ * [x] Lint newly added crates for the fields required to publish to crates.io <!-- What are the changes this PR brings about? --> <!-- Example: This PR adds a PR template to the repo. --> <!-- (For bigger PRs adding more context is appreciated) --> ## Why ❔ To prevent issues with `crates.io` publishing on the later stages caused by missing fields in new `Cargo.toml` files. <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- The `Why` has to be clear to non-Matter Labs entities running their own ZK Chain --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## Tests Tested in a separate workflow with multiple crates with wrong configuration: https://github.com/matter-labs/zksync-era/actions/runs/17213648618/job/48831624156 <img width="883" height="75" alt="image" src="https://github.com/user-attachments/assets/c4bb468f-55ef-4e7e-8cf4-ef827c37b852" /> ## Is this a breaking change? - [ ] Yes - [x] No ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zkstack dev fmt` and `zkstack dev lint`.
1 parent b94016c commit db5741c

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/ci-core-lint-reusable.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,53 @@ on:
33
workflow_call:
44

55
jobs:
6+
7+
# Linter for new crates
8+
# checks that all required fields are present in Cargo.toml files of newly added crates
9+
check-new-crates:
10+
name: Check new crates
11+
runs-on: ubuntu-latest
12+
steps:
13+
14+
- name: Checkout
15+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
16+
17+
- name: Get changed files
18+
id: changed-files
19+
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46
20+
with:
21+
files: '**/Cargo.toml'
22+
23+
- name: Lint Cargo.toml files of new crates
24+
if: ${{ steps.changed-files.outputs.added_files != '' }}
25+
env:
26+
ADDED_FILES: ${{ steps.changed-files.outputs.added_files }}
27+
REQUIRED_FIELDS: 'name version edition description license'
28+
run: |
29+
MISSING_ANY=false
30+
for FILE in ${ADDED_FILES}; do
31+
echo "✅ New crate added: ${FILE}"
32+
PACKAGE_NAME="$(yq -oy .package.name ${FILE})"
33+
echo "Checking required fields fields for a new package ${PACKAGE_NAME}..."
34+
MISSING_FIELDS=""
35+
for FIELD in ${REQUIRED_FIELDS}; do
36+
if ! yq -oy -e .package.${FIELD} ${FILE} > /dev/null 2>&1; then
37+
echo "Error: missing field '${FIELD}' in ${FILE} for crates.io publishing!"
38+
MISSING_FIELDS="${MISSING_FIELDS} ${FIELD}"
39+
MISSING_ANY=true
40+
fi
41+
done
42+
if [ "${MISSING_FIELDS}" != "" ]; then
43+
echo "----------------------------------------"
44+
echo "❌ Error: missing fields '$(echo "${MISSING_FIELDS}" | xargs)' in ${FILE} for crates.io publishing!"
45+
echo "❌ Please, add all required fields to the Cargo.toml file of the new crate."
46+
echo "----------------------------------------"
47+
fi
48+
done
49+
if [[ "${MISSING_ANY}" == true ]]; then
50+
exit 1
51+
fi
52+
653
code_lint:
754
runs-on: matterlabs-ci-runner-highmem-long
855
steps:

0 commit comments

Comments
 (0)