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

feat: adds zk linkcheck to zk tool and updates zk env for zk linkcheck ci usage #868

Merged
merged 7 commits into from
Jan 15, 2024
Merged
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions checks-config/links.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"ignorePatterns": [
{
"pattern": "^https://github\\.com/matter-labs/zksync-2-dev/"
},
{
"pattern": "^https://www\\.notion\\.so/"
},
{
"pattern": "^https://github\\.com/matter-labs/zksync-era/compare/"
},
{
"pattern": "^https://twitter\\.com/zksync"
},
{
"pattern": "^https://twitter\\.com/zkSyncDevs"
},
{
"pattern": "^https://github\\.com/matter-labs/zk_evm"
},
{
"pattern": "^https://sepolia\\.etherscan\\.io/tx/0x18c2a113d18c53237a4056403047ff9fafbf772cb83ccd44bb5b607f8108a64c"
},
{
"pattern": "^https://github\\.com/matter-labs/zksync-era/commit/"
}
],
"aliveStatusCodes": [0, 200, 206, 304]
}
2 changes: 1 addition & 1 deletion core/lib/dal/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub struct ConnectionPool {
impl fmt::Debug for ConnectionPool {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
// We don't print the `database_url`, as is may contain
// sensistive information (e.g. database password).
// sensitive information (e.g. database password).
formatter
.debug_struct("ConnectionPool")
.field("max_size", &self.max_size)
Expand Down
2 changes: 1 addition & 1 deletion core/lib/zksync_core/src/consensus/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ impl PersistentBlockStore for BlockStore {
ctx: &ctx::Ctx,
block: &validator::FinalBlock,
) -> ctx::Result<()> {
// This mutex prevents concurrent store_next_block calls.
// This mutex prevents concurrent `store_next_block` calls.
let mut guard = ctx.wait(self.store_next_block_mutex.lock()).await?;
if let Some(cursor) = &mut *guard {
cursor.advance(block).await.context("cursor.advance()")?;
Expand Down
2 changes: 1 addition & 1 deletion core/lib/zksync_core/src/consensus/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl MainNodeClient for MockMainNodeClient {

/// Fake StateKeeper for tests.
pub(super) struct StateKeeper {
// Batch of the last_block.
// Batch of the `last_block`.
last_batch: L1BatchNumber,
last_block: MiniblockNumber,
// timestamp of the last block.
Expand Down
4 changes: 2 additions & 2 deletions core/lib/zksync_core/src/consensus/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async fn test_validator_block_store() {

// In the current implementation, consensus certificates are created asynchronously
// for the miniblocks constructed by the StateKeeper. This means that consensus actor
// is effectively just backfilling the consensus certificates for the miniblocks in storage.
// is effectively just back filling the consensus certificates for the miniblocks in storage.
#[tokio::test(flavor = "multi_thread")]
async fn test_validator() {
zksync_concurrency::testonly::abort_on_panic();
Expand Down Expand Up @@ -253,7 +253,7 @@ async fn test_fetcher() {
.unwrap();
}

// Test fetcher backfilling missing certs.
// Test fetcher back filling missing certs.
#[tokio::test(flavor = "multi_thread")]
async fn test_fetcher_backfill_certs() {
zksync_concurrency::testonly::abort_on_panic();
Expand Down
2 changes: 1 addition & 1 deletion docker/local-node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN mkdir -p /etc/apt/keyrings && \
wget -c -O - https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && apt-get install nodejs npm -y && \
npm install -g yarn
npm install -g yarn && npm install -g cspell && npm install -g markdown-link-check

# Copy compiler (both solc and zksolc) binaries
# Obtain `solc` 0.8.12.
Expand Down
2 changes: 1 addition & 1 deletion docker/zk-environment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ RUN mkdir -p /etc/apt/keyrings && \
wget -c -O - https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && apt-get install nodejs npm -y && \
npm install -g yarn && npm install -g cspell@latest
npm install -g yarn && npm install -g cspell && npm install -g markdown-link-check
dutterbutter marked this conversation as resolved.
Show resolved Hide resolved

# Install Rust and required cargo packages
ENV RUSTUP_HOME=/usr/local/rustup \
Expand Down
18 changes: 17 additions & 1 deletion docs/guides/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,27 @@ the spell check, use the following command:
zk spellcheck
Options:
--pattern <pattern>: Specifies the glob pattern for files to check. Default is docs/**/*.
--config <config>: Path to the configuration file. Default is ./spellcheck/cspell.json.
--use-cargo: Utilize cargo spellcheck.
--use-cspell: Utilize cspell.
```

## Link Checking

To maintain the integrity and reliability of our documentation, we make use of a link checking process using the
`markdown-link-check` tool. This ensures that all links in our markdown files are valid and accessible. The following
section describes how to use this tool and configure it for specific needs.

### Using the Link Check Command

The link check command `zk linkcheck` is designed to verify the integrity of links in our markdown files. To execute the
link check, use the following command:

```
zk linkcheck
Options:
--config <config>: Path to the markdown-link-check configuration file. Default is './checks-config/links.json'.
```

### General Rules

**Code References in Comments**: When referring to code elements within development comments, they should be wrapped in
Expand Down
5 changes: 3 additions & 2 deletions infrastructure/zk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"@types/tabtab": "^3.0.1",
"hardhat": "=2.16.0",
"typescript": "^4.3.5",
"cspell": "*",
"sql-formatter": "^13.1.0"
"cspell": "^8.3.2",
"sql-formatter": "^13.1.0",
"markdown-link-check": "^3.11.2"
}
}
2 changes: 2 additions & 0 deletions infrastructure/zk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { command as verifyUpgrade } from './verify-upgrade';
import { proverCommand } from './prover_setup';
import { command as status } from './status';
import { command as spellcheck } from './spellcheck';
import { command as linkcheck } from './linkcheck';
import * as env from './env';

const COMMANDS = [
Expand Down Expand Up @@ -50,6 +51,7 @@ const COMMANDS = [
env.command,
status,
spellcheck,
linkcheck,
completion(program as Command)
];

Expand Down
25 changes: 25 additions & 0 deletions infrastructure/zk/src/linkcheck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Command } from 'commander';
import * as utils from './utils';

export async function runMarkdownLinkCheck(configPath: string) {
// Command line usage for markdown-link-check suggests using find and xargs for
// recursive checks. See: `https://github.com/tcort/markdown-link-check?tab=readme-ov-file#check-links-from-a-local-markdown-folder-recursive`
const findCommand = `find . -name "*.md" ! -path "*/node_modules/*" ! -path "*/target/release/*" ! -path "*/build/*" ! -path "*/contracts/*" -print0`;
const markdownLinkCheckCommand = `xargs -0 -n1 markdown-link-check --config ${configPath}`;
const fullCommand = `${findCommand} | ${markdownLinkCheckCommand}`;

try {
await utils.spawn(fullCommand);
console.log('Markdown link check completed successfully');
} catch (error) {
console.error('Error occurred during markdown link checking:', error);
process.exit(1);
}
}

export const command = new Command('linkcheck')
.option('--config <config>', 'Path to configuration file', './checks-config/links.json')
.description('Run markdown link check on specified files')
.action((cmd) => {
runMarkdownLinkCheck(cmd.config);
});
6 changes: 3 additions & 3 deletions infrastructure/zk/src/spellcheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import * as utils from './utils';

export async function runSpellCheck(pattern: string, useCargo: boolean, useCSpell: boolean) {
// Default commands for cSpell and cargo spellcheck
const cSpellCommand = `cspell "${pattern}" --config=./spellcheck/cspell.json`;
const cargoCommand = `cargo spellcheck --cfg=./spellcheck/era.cfg`;
const cSpellCommand = `cspell "${pattern}" --config=./checks-config/cspell.json`;
const cargoCommand = `cargo spellcheck --cfg=./checks-config/era.cfg --code 1`;
// Necessary to run cargo spellcheck in the prover directory explicitly as
// it is not included in the root cargo.toml file
const cargoCommandForProver = `cargo spellcheck --cfg=../spellcheck/era.cfg`;
const cargoCommandForProver = `cargo spellcheck --cfg=../checks-config/era.cfg --code 1`;

try {
let results = [];
Expand Down