Skip to content

Commit a8039f3

Browse files
committed
Merge remote-tracking branch 'origin/main' into feature/add-ci-coveralls
2 parents f2ed639 + 0eecf70 commit a8039f3

File tree

12 files changed

+179
-153
lines changed

12 files changed

+179
-153
lines changed

.github/workflows/ci-tests-n-coverage.yml

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ concurrency:
1616
cancel-in-progress: true
1717

1818
jobs:
19-
monorepo:
19+
unit-tests:
2020
name: Catalyst Core Tests and Code Coverage
2121
runs-on: ubuntu-latest
2222
env:
@@ -28,6 +28,15 @@ jobs:
2828
ref: ${{ github.event.pull_request.head.sha }}
2929

3030
- uses: Swatinem/rust-cache@v2
31+
with:
32+
shared-key: "cov"
33+
save-if: "true"
34+
35+
- name: Install Rust toolchain
36+
uses: actions-rs/toolchain@v1
37+
with:
38+
toolchain: "1.65" # it says it can read the rust-toolchain file, but it fails if we omit this
39+
components: llvm-tools-preview
3140

3241
- name: Install cargo-nextest
3342
run: curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
@@ -39,21 +48,16 @@ jobs:
3948
run:
4049
sudo apt install -y protobuf-compiler libssl-dev libpq-dev libsqlite3-dev pkg-config
4150

42-
- name: Install Rust toolchain
43-
uses: actions-rs/toolchain@v1
44-
with:
45-
toolchain: "1.65" # it says it can read the rust-toolchain file, but it fails if we omit this
46-
4751
- run: |
4852
cargo llvm-cov nextest --no-report --manifest-path ./src/catalyst-toolbox/catalyst-toolbox/Cargo.toml --profile ci
4953
cargo llvm-cov nextest --no-report --manifest-path ./src/catalyst-toolbox/snapshot-lib/Cargo.toml --profile ci
50-
- run: |
54+
5155
cargo llvm-cov nextest --no-report --manifest-path ./src/vit-servicing-station/vit-servicing-station-cli/Cargo.toml --profile ci
5256
cargo llvm-cov nextest --no-report --manifest-path ./src/vit-servicing-station/vit-servicing-station-lib/Cargo.toml --profile ci
5357
cargo llvm-cov nextest --no-report --manifest-path ./src/vit-servicing-station/vit-servicing-station-server/Cargo.toml --profile ci
54-
- run:
58+
5559
cargo llvm-cov nextest --no-report --manifest-path ./src/voting-tools-rs/Cargo.toml --profile ci
56-
- run: |
60+
5761
cargo llvm-cov nextest --no-report --manifest-path ./src/chain-libs/cardano-legacy-address/Cargo.toml --profile ci
5862
cargo llvm-cov nextest --no-report --manifest-path ./src/chain-libs/chain-addr/Cargo.toml --profile ci
5963
cargo llvm-cov nextest --no-report --manifest-path ./src/chain-libs/chain-core/Cargo.toml --profile ci
@@ -75,22 +79,25 @@ jobs:
7579
cargo llvm-cov nextest --no-report --manifest-path ./src/chain-wallet-libs/hdkeygen/Cargo.toml --profile ci
7680
cargo llvm-cov nextest --no-report --manifest-path ./src/chain-wallet-libs/symmetric-cipher/Cargo.toml --profile ci
7781
cargo llvm-cov nextest --no-report --manifest-path ./src/chain-wallet-libs/wallet/Cargo.toml --profile ci
78-
- run:
82+
7983
cargo llvm-cov nextest --no-report --manifest-path ./src/jormungandr/jormungandr/Cargo.toml --profile ci
84+
cargo llvm-cov report --lcov --output-path ./lcov.info
85+
- name: Upload code coverage to coveralls.io
86+
uses: coverallsapp/github-action@master
87+
with:
88+
github-token: ${{ secrets.GITHUB_TOKEN }}
89+
path-to-lcov: "./lcov.info"
8090

91+
integration-tests:
92+
name: Catalyst Core Tests and Code Coverage
93+
runs-on: ubuntu-latest
94+
env:
95+
CARGO_FLAGS: --verbose --locked
96+
steps:
8197
- name: Integration tests
8298
run: |
8399
echo "Integration test coverage is temporarily disabled."
84100
# source <(cargo llvm-cov show-env --export-prefix)
85101
# cargo build -p jcli -p jormungandr -p explorer -p vit-servicing-station-cli -p vit-servicing-station-server
86102
# cargo llvm-cov nextest --no-report --manifest-path ./src/vit-servicing-station/vit-servicing-station-tests/Cargo.toml --profile ci
87103
# cargo llvm-cov nextest --no-report --manifest-path ./src/jormungandr/testing/jormungandr-integration-tests/Cargo.toml --profile ci
88-
89-
- run:
90-
cargo llvm-cov report --lcov --output-path ./lcov.info
91-
92-
- name: Upload code coverage to coveralls.io
93-
uses: coverallsapp/github-action@master
94-
with:
95-
github-token: ${{ secrets.GITHUB_TOKEN }}
96-
path-to-lcov: "./lcov.info"

.github/workflows/ci_tests.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ jobs:
138138
sudo apt install -y protobuf-compiler libssl-dev libpq-dev libsqlite3-dev pkg-config
139139

140140
- name: Run chain-libs tests
141-
- run: |
141+
run: |
142142
source <(cargo llvm-cov show-env --export-prefix)
143143
cargo llvm-cov nextest --no-report --manifest-path ./src/chain-libs/cardano-legacy-address/Cargo.toml --profile ci
144144
cargo llvm-cov nextest --no-report --manifest-path ./src/chain-libs/chain-addr/Cargo.toml --profile ci
@@ -182,6 +182,8 @@ jobs:
182182
components: llvm-tools-preview
183183
- name: Install Nextest
184184
run: curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
185+
- name: Install cargo-llvm-cov
186+
uses: taiki-e/install-action@cargo-llvm-cov
185187
- name: Install deps
186188
run:
187189
sudo apt install -y protobuf-compiler libssl-dev libpq-dev libsqlite3-dev pkg-config
@@ -228,9 +230,15 @@ jobs:
228230
runs-on: ubuntu-latest
229231
needs: [vit_servicing_station, catalyst_toolbox, voting_tools, chain-libs, jormungandr, jormungandr-integration]
230232
steps:
233+
- name: Checkout code
234+
uses: actions/checkout@v3
235+
with:
236+
ref: ${{ github.event.pull_request.head.sha }}
231237
- uses: Swatinem/rust-cache@v2
232238
with:
233239
shared-key: "cov"
240+
- name: Install cargo-llvm-cov
241+
uses: taiki-e/install-action@cargo-llvm-cov
234242
- name: Generate lcov.info
235243
run: cargo llvm-cov report --lcov --output-path ./lcov.info
236244

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
shell-profile-5-link
1+
shell-profile-14-link

flake.lock

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
66

77
## Std ##
8-
std.url = "github:divnix/std";
8+
std.url = "github:divnix/std/target-in-actions";
99
std.inputs.nixpkgs.follows = "nixpkgs";
1010

1111
# Rust overlay

nix/artifacts/artifacts.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
cell,
44
}: let
55
inherit (inputs) nixpkgs std;
6-
inherit (inputs.cells.lib) constants;
6+
inherit (inputs.cells.lib) lib;
77
l = nixpkgs.lib // builtins;
88

99
mkArtifact = namespace:
@@ -16,4 +16,4 @@
1616
'';
1717
};
1818
in
19-
constants.mapToNamespaces {prefix = "artifacts";} mkArtifact
19+
lib.mapToNamespaces "artifacts" mkArtifact

nix/jormungandr/containers.nix

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@
33
cell,
44
}: let
55
inherit (inputs) nixpkgs std;
6-
inherit (inputs.cells.lib) constants;
6+
inherit (inputs.cells.lib) constants lib;
77
l = nixpkgs.lib // builtins;
88

9-
mkOCI = name: let
10-
operable = cell.operables.${name};
9+
mkOCI = namespace: let
10+
# TODO: fix git rev
11+
rev =
12+
if (inputs.self.rev != "not-a-commit")
13+
then inputs.self.rev
14+
else "dirty";
1115
in
1216
std.lib.ops.mkStandardOCI {
13-
inherit operable;
14-
name = "${constants.registry}/${name}";
17+
name = "${constants.registry}/jormungandr";
18+
tag = "${rev}-${namespace}";
19+
operable = cell.operables."jormungandr-${namespace}";
1520
debug = true;
1621
};
17-
in {
18-
jormungandr = mkOCI "jormungandr";
19-
}
22+
in
23+
{}
24+
// lib.mapToNamespaces "jormungandr" mkOCI

nix/jormungandr/operables.nix

Lines changed: 59 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,71 +4,67 @@
44
}: let
55
inherit (inputs) nixpkgs std;
66
inherit (inputs.cells.artifacts) artifacts;
7-
inherit (inputs.cells.lib) constants;
7+
inherit (inputs.cells.lib) lib;
88
l = nixpkgs.lib // builtins;
99

1010
package = cell.packages.jormungandr;
11-
in {
12-
jormungandr = std.lib.ops.mkOperable {
13-
inherit package;
14-
# TODO: Remove all the bitte stuff
15-
# TODO: update artifact path to correct mount path
16-
runtimeScript = ''
17-
ulimit -n 1024
1811

19-
nodeConfig="$NOMAD_TASK_DIR/node-config.json"
20-
runConfig="$NOMAD_TASK_DIR/running.json"
21-
runYaml="$NOMAD_TASK_DIR/running.yaml"
22-
23-
chmod u+rwx -R "$NOMAD_TASK_DIR" || true
24-
25-
function convert () {
12+
mkOperable = namespace: let
13+
artifacts' = artifacts."artifacts-${namespace}";
14+
in
15+
std.lib.ops.mkOperable {
16+
inherit package;
17+
# TODO: Remove all the bitte stuff
18+
runtimeScript = ''
19+
ulimit -n 1024
20+
nodeConfig="$NOMAD_TASK_DIR/node-config.json"
21+
runConfig="$NOMAD_TASK_DIR/running.json"
22+
runYaml="$NOMAD_TASK_DIR/running.yaml"
2623
chmod u+rwx -R "$NOMAD_TASK_DIR" || true
27-
cp "$nodeConfig" "$runConfig"
28-
remarshal --if json --of yaml "$runConfig" > "$runYaml"
29-
}
30-
31-
if [ "$RESET" = "true" ]; then
32-
echo "RESET is given, will start from scratch..."
33-
rm -rf "$STORAGE_DIR"
34-
elif [ -d "$STORAGE_DIR" ]; then
35-
echo "$STORAGE_DIR found, not restoring from backup..."
36-
else
37-
echo "$STORAGE_DIR not found, restoring backup..."
38-
39-
restic restore latest \
40-
--verbose=5 \
41-
--no-lock \
42-
--tag "$NAMESPACE" \
43-
--target / \
44-
|| echo "couldn't restore backup, continue startup procedure..."
45-
fi
46-
47-
set +x
48-
echo "waiting for $REQUIRED_PEER_COUNT peers"
49-
until [ "$(jq -e -r '.p2p.trusted_peers | length' < "$nodeConfig" || echo 0)" -ge "$REQUIRED_PEER_COUNT" ]; do
50-
sleep 1
51-
done
52-
set -x
53-
54-
convert
55-
56-
if [ -n "$PRIVATE" ]; then
57-
echo "Running with node with secrets..."
58-
exec ${l.getExe package} \
59-
--storage "$STORAGE_DIR" \
60-
--config "$NOMAD_TASK_DIR/running.yaml" \
61-
--genesis-block "artifacts/block0.bin" \
62-
--secret "$NOMAD_SECRETS_DIR/bft-secret.yaml" \
63-
"$@" || true
64-
else
65-
echo "Running with follower node..."
66-
exec ${l.getExe package} \
67-
--storage "$STORAGE_DIR" \
68-
--config "$NOMAD_TASK_DIR/running.yaml" \
69-
--genesis-block "artifacts/block0.bin" \
70-
"$@" || true
71-
fi
72-
'';
73-
};
74-
}
24+
function convert () {
25+
chmod u+rwx -R "$NOMAD_TASK_DIR" || true
26+
cp "$nodeConfig" "$runConfig"
27+
remarshal --if json --of yaml "$runConfig" > "$runYaml"
28+
}
29+
if [ "$RESET" = "true" ]; then
30+
echo "RESET is given, will start from scratch..."
31+
rm -rf "$STORAGE_DIR"
32+
elif [ -d "$STORAGE_DIR" ]; then
33+
echo "$STORAGE_DIR found, not restoring from backup..."
34+
else
35+
echo "$STORAGE_DIR not found, restoring backup..."
36+
restic restore latest \
37+
--verbose=5 \
38+
--no-lock \
39+
--tag "$NAMESPACE" \
40+
--target / \
41+
|| echo "couldn't restore backup, continue startup procedure..."
42+
fi
43+
set +x
44+
echo "waiting for $REQUIRED_PEER_COUNT peers"
45+
until [ "$(jq -e -r '.p2p.trusted_peers | length' < "$nodeConfig" || echo 0)" -ge "$REQUIRED_PEER_COUNT" ]; do
46+
sleep 1
47+
done
48+
set -x
49+
convert
50+
if [ -n "$PRIVATE" ]; then
51+
echo "Running with node with secrets..."
52+
exec ${l.getExe package} \
53+
--storage "$STORAGE_DIR" \
54+
--config "$NOMAD_TASK_DIR/running.yaml" \
55+
--genesis-block "${artifacts'}/block0.bin" \
56+
--secret "$NOMAD_SECRETS_DIR/bft-secret.yaml" \
57+
"$@" || true
58+
else
59+
echo "Running with follower node..."
60+
exec ${l.getExe package} \
61+
--storage "$STORAGE_DIR" \
62+
--config "$NOMAD_TASK_DIR/running.yaml" \
63+
--genesis-block "${artifacts'}/block0.bin" \
64+
"$@" || true
65+
fi
66+
'';
67+
};
68+
in
69+
{}
70+
// lib.mapToNamespaces "jormungandr" mkOperable

nix/lib/constants.nix

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,33 @@
44
}: let
55
inherit (inputs) nixpkgs;
66
l = nixpkgs.lib // builtins;
7+
in rec {
8+
# The current funding round we are in
9+
fundRound = 10;
10+
11+
# The current SVE round we are in
12+
sveRound = 2;
713

14+
# List of target environments we generate artifacts for
815
envs = [
916
"dev"
1017
"signoff"
1118
"perf"
1219
"dryrun"
1320
"prod"
1421
];
15-
events = [
16-
"fund10"
17-
"sve1"
18-
"sve2"
19-
];
2022

21-
mkNamespaces = event: l.map (env: "${event}-${env}") envs;
22-
in rec {
23-
inherit envs events;
24-
namespaces = l.flatten (l.map (event: mkNamespaces event) events);
25-
registry = "432820653916.dkr.ecr.eu-central-1.amazonaws.com";
23+
# A list of all possible round/namespace combinations
24+
# fund10-dev, fund10-dryrun, sve2-signoff, sve2-prod, etc.
25+
namespaces = let
26+
events = [
27+
"fund${l.toString fundRound}"
28+
"sve${l.toString sveRound}"
29+
];
30+
mkNamespaces = event: l.map (env: "${event}-${env}") envs;
31+
in
32+
l.flatten (l.map (event: mkNamespaces event) events);
2633

27-
mapToNamespaces = {
28-
prefix ? "",
29-
suffix ? "",
30-
}: fn:
31-
l.listToAttrs (
32-
l.map
33-
(
34-
namespace: {
35-
name =
36-
if prefix != ""
37-
then
38-
if suffix != ""
39-
then "${prefix}-${namespace}-${suffix}"
40-
else "${prefix}-${namespace}"
41-
else "${namespace}";
42-
value = fn namespace;
43-
}
44-
)
45-
namespaces
46-
);
34+
# The OCI registry we are pushing to
35+
registry = "432820653916.dkr.ecr.eu-central-1.amazonaws.com";
4736
}

0 commit comments

Comments
 (0)