-
Notifications
You must be signed in to change notification settings - Fork 73
170 lines (142 loc) · 4.39 KB
/
code.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
164
165
166
167
168
169
170
on:
push:
branches:
- main
pull_request:
name: Code
jobs:
test-native:
name: Test Native
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.3
- name: Run cargo test
run: cargo test --features signaling --all-targets
# Should be upgraded to test when possible
check-wasm:
name: Check Wasm
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: wasm32-unknown-unknown
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.3
- name: Run cargo check
run: RUSTFLAGS=--cfg=web_sys_unstable_apis cargo check >
--all-targets
--target wasm32-unknown-unknown
-p matchbox_socket
-p bevy_matchbox
-p bevy_ggrs_example
-p simple_example
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.3
- name: Run cargo clippy
run: cargo fmt --all --check
lint-native:
name: Lints native
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.3
- name: Run cargo clippy
run: cargo clippy --all-targets -- -D warnings
lint-wasm:
name: Clippy wasm
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: wasm32-unknown-unknown
components: clippy
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.3
- name: Run cargo clippy
run: RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy >
--all-targets
--target wasm32-unknown-unknown
-p matchbox_socket
-p bevy_matchbox
-p bevy_ggrs_example
-p simple_example
--
-D warnings
server-container:
name: Build & Push Server Container
needs: [test-native, check-wasm, lint-native, lint-wasm]
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Generate Image Name
run: echo IMAGE_REPOSITORY=ghcr.io/$(tr '[:upper:]' '[:lower:]' <<< "${{ github.repository }}")/matchbox_server >> $GITHUB_ENV
- name: Log in to GitHub Docker Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_REPOSITORY }}
tags: |
type=ref,event=tag
type=raw,value=latest
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Image
uses: docker/build-push-action@v5
with:
context: "."
file: "matchbox_server/Dockerfile"
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
load: ${{ ! (github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max