-
Notifications
You must be signed in to change notification settings - Fork 7
164 lines (150 loc) · 4.68 KB
/
queue_and_merge.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: Check Stuff 👨🔧
on:
merge_group:
pull_request:
push:
branches:
- main
concurrency:
group: ${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions:
packages: write
pages: write
id-token: write
contents: read
jobs:
clippy:
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@just
- uses: rui314/setup-mold@v1
- uses: heliaxdev/setup-protoc@v2
with:
version: "25.0"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache: true
- run: just clippy
validate-swagger:
runs-on: ubuntu-latest
name: Validate Swagger
steps:
- uses: actions/checkout@v4
- name: Validate OpenAPI definition
uses: char0n/[email protected]
with:
definition-file: swagger.yml
format:
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@just
- uses: rui314/setup-mold@v1
- uses: heliaxdev/setup-protoc@v2
with:
version: "25.0"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly
components: rustfmt
cache: true
- run: just fmt
build:
if: ${{ github.event_name == 'pull_request' }}
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@just
- uses: rui314/setup-mold@v1
- uses: heliaxdev/setup-protoc@v2
with:
version: "25.0"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache: true
- run: just build
docker:
name: Docker
runs-on: ubuntu-latest
if: ${{ github.event_name == 'merge_group' || github.ref == 'refs/heads/main' }}
env:
GIT_LFS_SKIP_SMUDGE: 1
REGISTRY_URL: ghcr.io
strategy:
fail-fast: true
matrix:
docker:
[
{ image: chain, package: chain },
{ image: governance, package: governance },
{ image: pos, package: pos },
{ image: rewards, package: rewards },
{ image: seeder, package: seeder },
{ image: webserver, package: webserver },
{ image: parameters, package: parameters },
{ image: transactions, package: transactions },
]
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
id: push
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
build-args: PACKAGE=${{matrix.docker.package}}
push: ${{ github.ref == 'refs/heads/main' }}
tags: ${{ env.REGISTRY_URL }}/anoma/namada-indexer:${{ matrix.docker.image }}-main
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
can_enqueue:
needs: [clippy, format, build, validate-swagger]
if: always() && github.event_name != 'merge_group'
permissions:
actions: read
runs-on: ubuntu-latest
steps:
- env:
NEEDS_JSON: "${{toJSON(needs)}}"
name: Transform outcomes
run: |
echo "ALL_SUCCESS=$(echo "$NEEDS_JSON" | jq '. | to_entries | map([.value.result == "success", .value.result == "skipped"] | any) | all')" >> $GITHUB_ENV
- name: check outcomes
run: "[ $ALL_SUCCESS == true ]"
can_merge:
needs: [clippy, format, docker, validate-swagger]
if: always() && github.event_name == 'merge_group'
permissions:
contents: read
pages: write
actions: read
id-token: write
runs-on: ubuntu-latest
steps:
- env:
NEEDS_JSON: "${{toJSON(needs)}}"
name: Transform outcomes
run: |
echo "ALL_SUCCESS=$(echo "$NEEDS_JSON" | jq '. | to_entries | map([.value.result == "success", .value.result == "skipped"] | any) | all')" >> $GITHUB_ENV
- name: check outcomes
run: "[ $ALL_SUCCESS == true ]"