-
Notifications
You must be signed in to change notification settings - Fork 3
140 lines (120 loc) · 3.54 KB
/
ci.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: continuous-integration
on:
pull_request:
paths-ignore:
- "**/*.md"
- "CODEOWNERS"
- "LICENSE"
- "FILE_TEMPLATE"
env:
DOCKERFILE: scripts/ci/dockerfiles/polkadot-introspector_injected.Dockerfile
CI_IMAGE: paritytech/ci-unified:bullseye-1.77.0
IMAGE_NAME: paritytech/polkadot-introspector
jobs:
set-image:
# GitHub Actions does not allow using 'env' in a container context.
# This workaround sets the container image for each job using 'set-image' job output.
runs-on: ubuntu-latest
outputs:
CI_IMAGE: ${{ steps.set_image.outputs.CI_IMAGE }}
steps:
- id: set_image
run: echo "CI_IMAGE=${{ env.CI_IMAGE }}" >> $GITHUB_OUTPUT
# lint
lint:
runs-on: ubuntu-latest
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache
uses: Swatinem/rust-cache@v2
- name: fmt
run: |
time cargo +nightly fmt --all -- --check
- name: Clippy
run: |
time cargo clippy --all-targets -- -D warnings
- name: Check
run: time cargo check --all-targets --workspace
# test
test:
runs-on: ubuntu-latest
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Test
run: |
rustup show
cargo --version
rustup +nightly show
cargo +nightly --version
bash --version
./scripts/ci/zombienet/zombie.sh setup
ZOMBIE_WS_PORT=9900 ./scripts/ci/zombienet/zombie.sh run ./scripts/ci/zombienet/network.toml
WS_URL=ws://127.0.0.1:9900 time cargo test --all-targets --workspace
./scripts/ci/zombienet/zombie.sh shutdown
# build
build:
runs-on: ubuntu-latest
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Build
run: |
time cargo build --release
- name: Archive aritfacts
uses: actions/upload-artifact@v4
with:
name: polkadot-introspector
path: |
target/release/polkadot-block-time
target/release/polkadot-jaeger
target/release/polkadot-kvdb
target/release/polkadot-parachain-tracer
target/release/polkadot-whois
retention-days: 1
# build docker image
build-docker:
runs-on: ubuntu-latest
needs: [set-image, build]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: polkadot-introspector
path: ./artifacts
- name: Set permissions
run: |
chmod +x ./artifacts/*
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build/Push Docker image
uses: docker/build-push-action@v6
with:
push: false
context: .
file: ${{ env.DOCKERFILE }}
build-args: |
VCS_REF="${{ github.sha }}"
build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
tags: |
${{ env.IMAGE_NAME }}:latest