Skip to content

Commit

Permalink
chore: small optimizations for the papyrus CI
Browse files Browse the repository at this point in the history
  • Loading branch information
alon-dotan-starkware committed Jul 17, 2024
1 parent 6b545af commit e81d09a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 61 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ jobs:
run: |
python3 -m venv ci
ci/bin/pip install -r scripts/requirements.txt
ci/bin/python scripts/run_tests.py --changes_only --commit_id ${{ github.base_ref }}
ci/bin/python scripts/run_tests.py --changes_only --features concurrency --commit_id ${{ github.base_ref }}
ci/bin/python scripts/run_tests.py --changes_only --commit_id ${{ github.base_ref }} --ci
ci/bin/python scripts/run_tests.py --changes_only --features concurrency --commit_id ${{ github.base_ref }} --ci
env:
SEED: 0

# Keep the name 'udeps' to match original action name, so we don't need to define specific branch
# rules on Github for specific version branches.
Expand Down Expand Up @@ -132,3 +134,16 @@ jobs:
cargo-udeps-*/cargo-udeps udeps
env:
RUSTUP_TOOLCHAIN: nightly-2024-01-12

check:
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: "-D warnings"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: Noelware/setup-protoc@1.1.0
with:
version: ${{env.PROTOC_VERSION}}
- run: cargo check --workspace -r --all-features
61 changes: 6 additions & 55 deletions .github/workflows/papyrus_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ env:
PROTOC_VERSION: v25.1

jobs:


executable-run:
runs-on: ubuntu-latest
steps:
Expand All @@ -34,10 +32,10 @@ jobs:
- uses: Noelware/setup-protoc@1.1.0
with:
version: ${{env.PROTOC_VERSION}}
- run: mkdir data

- name: Build node
run: cargo build -r
run: |
mkdir data
cargo build -r
- name: Run executable
run: >
Expand All @@ -53,32 +51,16 @@ jobs:
- uses: Noelware/setup-protoc@1.1.0
with:
version: ${{env.PROTOC_VERSION}}
- run: mkdir data

- name: Build node
run: cargo build -r --no-default-features
run: |
mkdir data
cargo build -r --no-default-features
- name: Run executable
run: >
target/release/papyrus_node --base_layer.node_url ${{ secrets.CI_BASE_LAYER_NODE_URL }}
& sleep 30 ; kill $!
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: Noelware/setup-protoc@1.1.0
with:
version: ${{env.PROTOC_VERSION}}
- run: npm install -g ganache@7.4.3

- run: |
cargo test --workspace -r
env:
SEED: 0
integration-test:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -109,22 +91,6 @@ jobs:
env:
SEED: 0
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
components: rustfmt
toolchain: nightly-2024-01-12
- uses: Swatinem/rust-cache@v2
- uses: Noelware/setup-protoc@1.1.0
with:
version: ${{env.PROTOC_VERSION}}

- run: cargo +nightly-2024-01-12 fmt --all -- --check

doc:
runs-on: ubuntu-latest
env:
Expand All @@ -136,23 +102,8 @@ jobs:
- uses: Noelware/setup-protoc@1.1.0
with:
version: ${{env.PROTOC_VERSION}}

- run: cargo doc --workspace -r --document-private-items --no-deps

check:
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: "-D warnings"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: Noelware/setup-protoc@1.1.0
with:
version: ${{env.PROTOC_VERSION}}

- run: cargo check --workspace -r --all-features

codecov:
runs-on: ubuntu-latest
steps:
Expand Down
24 changes: 20 additions & 4 deletions scripts/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def get_local_changes(repo_path, commit_id: Optional[str]) -> List[str]:
except ValueError:
print(f"unable to validate {repo_path} as a git repo.")
raise

return [c.a_path for c in repo.head.commit.diff(None)]
return [c.a_path for c in repo.head.commit.diff(commit_id)]


def get_modified_packages(files: List[str]) -> Set[str]:
Expand Down Expand Up @@ -61,7 +61,15 @@ def get_package_dependencies(package_name: str) -> Set[str]:
return deps


def run_test(changes_only: bool, commit_id: Optional[str], features: Optional[str] = None):
def run_test(
changes_only: bool,
commit_id: Optional[str],
features: Optional[str] = None,
ci: bool = False
):
if ci:
commit_id = f'origin/{commit_id}'

local_changes = get_local_changes(".", commit_id=commit_id)
modified_packages = get_modified_packages(local_changes)
args = []
Expand Down Expand Up @@ -93,12 +101,20 @@ def parse_args() -> argparse.Namespace:
parser.add_argument(
"--commit_id", type=str, help="GIT commit ID to compare against."
)
parser.add_argument(
"--ci", action="store_true", help="GIT commit ID to compare against."
)
return parser.parse_args()


def main():
args = parse_args()
run_test(changes_only=args.changes_only, commit_id=args.commit_id, features=args.features)
run_test(
changes_only=args.changes_only,
commit_id=args.commit_id,
features=args.features,
ci=args.ci
)


if __name__ == "__main__":
Expand Down

0 comments on commit e81d09a

Please sign in to comment.