forked from zkcrypto/bls12_381
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (71 loc) · 3.83 KB
/
check-downstream-compiles.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Check downstream compiles
on:
push:
branches:
- zkvm
pull_request:
branches:
- zkvm
jobs:
check-aptos-lc-compiles:
runs-on: ubuntu-latest
steps:
- name: Set up git private repo access
run: |
git config --global url."https://${{ secrets.REPO_TOKEN }}@github.com/".insteadOf ssh://git@github.com
git config --global url."https://${{ secrets.REPO_TOKEN }}@github.com".insteadOf https://github.com
- uses: actions/checkout@v4
with:
repository: lurk-lab/ci-workflows
- uses: ./.github/actions/ci-env
- uses: ./.github/actions/install-deps
with:
packages: "pkg-config libudev-dev"
- uses: Swatinem/rust-cache@v2
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@nextest
- name: Set env
run: |
echo "DOWNSTREAM_REPO=$(echo "wormhole-foundation/example-zk-light-clients-internal" | awk -F'/' '{ print $2 }')" | tee -a $GITHUB_ENV
echo "UPSTREAM_REPO=$(echo "lurk-lab/bls12_381" | awk -F'/' '{ print $2 }')" | tee -a $GITHUB_ENV
- uses: actions/checkout@v4
with:
path: ${{ github.workspace }}/${{ env.UPSTREAM_REPO }}
submodules: recursive
- uses: actions/checkout@v4
with:
repository: "wormhole-foundation/${{ env.DOWNSTREAM_REPO }}"
path: ${{ github.workspace }}/${{ env.DOWNSTREAM_REPO }}
token: ${{ secrets.REPO_TOKEN }}
submodules: recursive
- name: Patch Cargo.toml
working-directory: ${{ github.workspace }}/${{ env.DOWNSTREAM_REPO }}/aptos
run: |
# Get each workspace package and relative path of the upstream crate, storing them in a map of former to latter
URL=ssh://git@github.com/${{ github.repository }}
# Assumes at least one dependency in the current workspace is used by the downstream crate
printf "\n[patch.'$URL']\n" | tee -a Cargo.toml
# Get a list of all upstream dependencies used by the downstream crate workspace
# This is done by checking for each instance of `git = <upstream_url>` in any of the downstream `Cargo.toml` files
DEPENDENCIES=$(grep -rsh "git = \"$URL\"" --include="Cargo.toml" .)
# Extract the dependency names and check for package renames, removing duplicates
DEP_NAMES=$(echo "$DEPENDENCIES" | awk '/package =/{for (i=1; i<=NF; i++) if ($i == "package") {name=$(i+2); print substr(name, 2, length(name)-2);} found=1} !/package =/{print $1}' | sort -u)
shopt -s nullglob
# Collect the `(package, path)` pairs for most subcrates in the upstream directory, regardless of whether it's a workspace member
SUBCRATES=$(find ../../${{ env.UPSTREAM_REPO }} \( -type d \( -name target -o -name examples -o -name tests -o -name cli \) -prune \) -o -name Cargo.toml -exec grep -A1 --no-group-separator -e "\[package\]" {} +)
SUBCRATES=$(echo "$SUBCRATES" | sed -n 'n;p' | awk -F '-name = "|"' '{split($1, parts, "/"); path=""; for(i=1; i<=length(parts)-1; i++) {path = path parts[i] "/"}; print $2, path}')
shopt -u nullglob
# Store the subcrates in associative array for retrieval when patching `Cargo.toml`
declare -A subcrates
while IFS= read -r line; do
pair=($line)
subcrates[${pair[0]}]=${pair[1]}
done <<< "$SUBCRATES"
# Write Git patches for each dependency used downstream
for crate in $DEP_NAMES; do
crate_path="${subcrates[$crate]}"
echo "$crate = { path = \"$crate_path\" }" | tee -a Cargo.toml
done
- name: Check downstream types don't break spectacularly
working-directory: ${{ github.workspace }}/${{ env.DOWNSTREAM_REPO }}/aptos
run: cargo check --workspace --tests --benches --examples