Skip to content

Commit dcd3727

Browse files
authored
feat(zk_toolbox): Move check sql to the lint step (#2757)
## What ❔ <!-- 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 ❔ <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zk fmt` and `zk lint`. --------- Signed-off-by: Danil <deniallugo@gmail.com>
1 parent 3757746 commit dcd3727

File tree

13 files changed

+92
-40
lines changed

13 files changed

+92
-40
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44

55
jobs:
66
code_lint:
7-
runs-on: [matterlabs-ci-runner]
7+
runs-on: [ matterlabs-ci-runner ]
88

99
steps:
1010
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
@@ -16,6 +16,8 @@ jobs:
1616
echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
1717
echo $(pwd)/bin >> $GITHUB_PATH
1818
echo IN_DOCKER=1 >> .env
19+
echo "prover_url=postgres://postgres:notsecurepassword@postgres:5432/zksync_local_prover" >> $GITHUB_ENV
20+
echo "core_url=postgres://postgres:notsecurepassword@postgres:5432/zksync_local" >> $GITHUB_ENV
1921
2022
- name: Start services
2123
run: |
@@ -27,6 +29,8 @@ jobs:
2729
ci_run ./bin/zkt
2830
ci_run yarn install
2931
ci_run git config --global --add safe.directory /usr/src/zksync
32+
ci_run zk_supervisor db setup --prover-url=${{ env.prover_url }} --core-url=${{ env.core_url }}
33+
3034
3135
- name: Lints
3236
run: |
@@ -36,3 +40,7 @@ jobs:
3640
ci_run zk_supervisor lint -t js --check
3741
ci_run zk_supervisor lint -t ts --check
3842
ci_run zk_supervisor lint -t rs --check
43+
44+
- name: Check Database
45+
run: |
46+
ci_run zk_supervisor database check-sqlx-data --prover-url=${{ env.prover_url }} --core-url=${{ env.core_url }}

.github/workflows/ci-zk-toolbox-reusable.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
uses: ./.github/workflows/ci-core-lint-reusable.yml
1212

1313
build:
14-
runs-on: [matterlabs-ci-runner]
14+
runs-on: [ matterlabs-ci-runner ]
1515

1616
steps:
1717
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
@@ -48,8 +48,8 @@ jobs:
4848
compression-level: 0
4949

5050
tests:
51-
runs-on: [matterlabs-ci-runner]
52-
needs: [build]
51+
runs-on: [ matterlabs-ci-runner ]
52+
needs: [ build ]
5353

5454
steps:
5555
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
@@ -115,9 +115,6 @@ jobs:
115115
--prover-db-url=postgres://postgres:notsecurepassword@postgres:5432 \
116116
--prover-db-name=zksync_prover_localhost_rollup
117117
118-
- name: Check Database
119-
run: |
120-
ci_run zk_supervisor database check-sqlx-data
121118
122119
- name: Run server
123120
run: |
@@ -137,11 +134,11 @@ jobs:
137134
- name: Run recovery tests (from snapshot)
138135
run: |
139136
ci_run zk_supervisor test recovery --snapshot --ignore-prerequisites --verbose
140-
137+
141138
- name: Run recovery tests (from genesis)
142139
run: |
143140
ci_run zk_supervisor test recovery --ignore-prerequisites --verbose
144-
141+
145142
- name: Run external node server
146143
run: |
147144
ci_run zk_inception external-node run --ignore-prerequisites &>external_node.log &
@@ -164,7 +161,7 @@ jobs:
164161
- name: Run upgrade test
165162
run: |
166163
ci_run zk_supervisor test upgrade
167-
164+
168165
- name: Show server.log logs
169166
if: always()
170167
run: ci_run cat server.log || true

zk_toolbox/crates/zk_supervisor/src/commands/database/args/mod.rs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,28 @@ use clap::Parser;
22

33
use crate::{
44
dals::SelectedDals,
5-
messages::{MSG_DATABASE_COMMON_CORE_HELP, MSG_DATABASE_COMMON_PROVER_HELP},
5+
messages::{
6+
MSG_DATABASE_COMMON_CORE_HELP, MSG_DATABASE_COMMON_CORE_URL_HELP,
7+
MSG_DATABASE_COMMON_PROVER_HELP, MSG_DATABASE_COMMON_PROVER_URL_HELP,
8+
},
69
};
710

811
pub mod new_migration;
912

1013
#[derive(Debug, Parser)]
1114
pub struct DatabaseCommonArgs {
12-
#[clap(short, long, default_missing_value = "true", num_args = 0..=1, help = MSG_DATABASE_COMMON_PROVER_HELP)]
15+
#[clap(
16+
short, long, default_missing_value = "true", num_args = 0..=1, help = MSG_DATABASE_COMMON_PROVER_HELP
17+
)]
1318
pub prover: Option<bool>,
14-
#[clap(short, long, default_missing_value = "true", num_args = 0..=1, help = MSG_DATABASE_COMMON_CORE_HELP)]
19+
#[clap(long, help = MSG_DATABASE_COMMON_PROVER_URL_HELP)]
20+
pub prover_url: Option<String>,
21+
#[clap(
22+
short, long, default_missing_value = "true", num_args = 0..=1, help = MSG_DATABASE_COMMON_CORE_HELP
23+
)]
1524
pub core: Option<bool>,
25+
#[clap(long, help = MSG_DATABASE_COMMON_CORE_URL_HELP)]
26+
pub core_url: Option<String>,
1627
}
1728

1829
impl DatabaseCommonArgs {
@@ -23,6 +34,10 @@ impl DatabaseCommonArgs {
2334
prover: true,
2435
core: true,
2536
},
37+
urls: DalUrls {
38+
prover: self.prover_url,
39+
core: self.core_url,
40+
},
2641
};
2742
}
2843

@@ -31,11 +46,22 @@ impl DatabaseCommonArgs {
3146
prover: self.prover.unwrap_or(false),
3247
core: self.core.unwrap_or(false),
3348
},
49+
urls: DalUrls {
50+
prover: self.prover_url,
51+
core: self.core_url,
52+
},
3453
}
3554
}
3655
}
3756

57+
#[derive(Debug, Clone)]
58+
pub struct DalUrls {
59+
pub prover: Option<String>,
60+
pub core: Option<String>,
61+
}
62+
3863
#[derive(Debug)]
3964
pub struct DatabaseCommonArgsFinal {
4065
pub selected_dals: SelectedDals,
66+
pub urls: DalUrls,
4167
}

zk_toolbox/crates/zk_supervisor/src/commands/database/check_sqlx_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn run(shell: &Shell, args: DatabaseCommonArgs) -> anyhow::Result<()> {
2525

2626
logger::info(msg_database_info(MSG_DATABASE_CHECK_SQLX_DATA_GERUND));
2727

28-
let dals = get_dals(shell, &args.selected_dals)?;
28+
let dals = get_dals(shell, &args.selected_dals, &args.urls)?;
2929
for dal in dals {
3030
check_sqlx_data(shell, &ecosystem_config.link_to_code, dal)?;
3131
}

zk_toolbox/crates/zk_supervisor/src/commands/database/drop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub async fn run(shell: &Shell, args: DatabaseCommonArgs) -> anyhow::Result<()>
2323

2424
logger::info(msg_database_info(MSG_DATABASE_DROP_GERUND));
2525

26-
let dals = get_dals(shell, &args.selected_dals)?;
26+
let dals = get_dals(shell, &args.selected_dals, &args.urls)?;
2727
for dal in dals {
2828
drop_database(dal).await?;
2929
}

zk_toolbox/crates/zk_supervisor/src/commands/database/migrate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn run(shell: &Shell, args: DatabaseCommonArgs) -> anyhow::Result<()> {
2323
logger::info(msg_database_info(MSG_DATABASE_MIGRATE_GERUND));
2424
let ecosystem_config = EcosystemConfig::from_file(shell)?;
2525

26-
let dals = get_dals(shell, &args.selected_dals)?;
26+
let dals = get_dals(shell, &args.selected_dals, &args.urls)?;
2727
for dal in dals {
2828
migrate_database(shell, &ecosystem_config.link_to_code, dal)?;
2929
}

zk_toolbox/crates/zk_supervisor/src/commands/database/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::messages::{
88
MSG_DATABASE_SETUP_ABOUT,
99
};
1010

11-
mod args;
11+
pub mod args;
1212
mod check_sqlx_data;
1313
mod drop;
1414
mod migrate;

zk_toolbox/crates/zk_supervisor/src/commands/database/new_migration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ pub fn run(shell: &Shell, args: DatabaseNewMigrationArgs) -> anyhow::Result<()>
1414
let args = args.fill_values_with_prompt();
1515

1616
let dal = match args.selected_database {
17-
SelectedDatabase::Core => get_core_dal(shell)?,
18-
SelectedDatabase::Prover => get_prover_dal(shell)?,
17+
SelectedDatabase::Core => get_core_dal(shell, None)?,
18+
SelectedDatabase::Prover => get_prover_dal(shell, None)?,
1919
};
2020
let ecosystem_config = EcosystemConfig::from_file(shell)?;
2121

zk_toolbox/crates/zk_supervisor/src/commands/database/prepare.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn run(shell: &Shell, args: DatabaseCommonArgs) -> anyhow::Result<()> {
2424

2525
logger::info(msg_database_info(MSG_DATABASE_PREPARE_GERUND));
2626

27-
let dals = get_dals(shell, &args.selected_dals)?;
27+
let dals = get_dals(shell, &args.selected_dals, &args.urls)?;
2828
for dal in dals {
2929
prepare_sqlx_data(shell, &ecosystem_config.link_to_code, dal)?;
3030
}

zk_toolbox/crates/zk_supervisor/src/commands/database/reset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub async fn run(shell: &Shell, args: DatabaseCommonArgs) -> anyhow::Result<()>
2424

2525
logger::info(msg_database_info(MSG_DATABASE_RESET_GERUND));
2626

27-
let dals = get_dals(shell, &args.selected_dals)?;
27+
let dals = get_dals(shell, &args.selected_dals, &args.urls)?;
2828
for dal in dals {
2929
logger::info(msg_database_loading(MSG_DATABASE_RESET_GERUND, &dal.path));
3030
reset_database(shell, ecoseystem_config.link_to_code.clone(), dal).await?;

0 commit comments

Comments
 (0)