-
Notifications
You must be signed in to change notification settings - Fork 32
72 lines (60 loc) · 1.89 KB
/
rust.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
name: Rust
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
CARGO_TERM_COLOR: always
SQLX_OFFLINE: true
MIN_PAYMENT_AMT: 100
INVOICE_EXPIRATION_WINDOW: 3600
DATABASE_URL: sqlite://./mostro.db
jobs:
tests:
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- name: Install Protoc
uses: arduino/setup-protoc@v3
- name: Select branch PR
if: ${{ github.ref != 'refs/heads/main' }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Select branch main
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/checkout@v4
with:
ref: main
- name: Install sqlx
run: cargo install sqlx-cli --version 0.6.2
- name: Init DB
run: |
sqlx database create || exit 1
# Verify database creation
test -f "./mostro.db" || { echo "Database file not created"; exit 1; }
- name: Run migrations
run: |
sqlx migrate run || exit 1
# Verify migrations
sqlx migrate info || exit 1
- name: Prepare offline file
run: cargo sqlx prepare
- name: Check offline file
run: cargo sqlx prepare --check
- name: Commit mostro.db and sqlx-data.json
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: 'chore(db): Update mostro.db and sqlx-data.json [skip ci]'
committer_name: GitHub Actions
committer_email: [email protected]
add: |
- mostro.db --force
- sqlx-data.json --force
- name: Run tests
run: cargo test --verbose