-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (110 loc) · 2.94 KB
/
test.yaml
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
name: "Test"
on:
push:
pull_request:
jobs:
sqlx:
name: "Verify Sqlx Cache"
runs-on: "ubuntu-latest"
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: postgres
ports:
- 5432:5432
env:
DATABASE_URL: "postgres://postgres:password@localhost/postgres"
steps:
- name: "Check out the repo"
uses: actions/checkout@v3
- name: "Setup Protoc"
uses: arduino/setup-protoc@v3
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- name: "Install SqlX"
run: cargo install sqlx-cli
- name: "Configure the database"
run: cargo sqlx database reset
- name: "Check the sqlx cache"
run: cargo sqlx prepare --check --workspace
check:
name: "Cargo check"
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: actions/checkout@v3
- name: "Setup Protoc"
uses: arduino/setup-protoc@v3
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- run: "cargo check"
test:
name: "Cargo test"
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: actions/checkout@v3
- name: "Setup Protoc"
uses: arduino/setup-protoc@v3
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- run: "cargo test --lib"
fmt:
name: "Cargo format"
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- run: "rustup component add rustfmt"
- run: "cargo fmt --all -- --check"
clippy:
name: "Cargo clippy"
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: actions/checkout@v3
- name: "Setup Protoc"
uses: arduino/setup-protoc@v3
- uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- run: "rustup component add clippy"
- run: "cargo clippy -- -D warnings"
create-tag:
name: "Create tag"
runs-on: "ubuntu-latest"
needs:
- sqlx
- check
- test
- fmt
- clippy
permissions:
contents: write
if: github.ref == 'refs/heads/main'
steps:
- name: "Check out the repo"
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: "Get tag"
id: "get-tag"
shell: "bash"
run: |
echo PKG_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2) }' ocpp/Cargo.toml) >> $GITHUB_OUTPUT
- name: "Set Tag"
shell: "bash"
run: |
git tag v${{ steps.get-tag.outputs.PKG_VERSION }} || true
- name: "Push Tags"
shell: "bash"
run: git push --tags || true