Repository navigation
98 lines (88 loc) · 2.66 KB
/
Copy pathtest-rust.yml
File metadata and controls
98 lines (88 loc) · 2.66 KB
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
name: Test Rust
on:
workflow_call:
inputs:
crate:
description: "Name of crate to test"
required: true
type: string
path:
description: "Path to container"
required: true
type: string
ref:
description: "Commit to test"
required: true
type: string
postgres:
description: "Start a PostgreSQL 18 service for the tests"
required: false
type: boolean
default: false
secrets:
CODECOV_TOKEN:
required: false
permissions:
contents: read
packages: read
jobs:
test:
name: Test ${{ inputs.crate }}
runs-on: ubuntu-24.04-arm
timeout-minutes: 15
container:
image: ${{ inputs.path }}
options: --user root
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Shares the server's socket directory, so tests can connect over it.
volumes:
- pg_socket:/var/run/postgresql
services:
postgres:
# An empty image skips the service.
image: ${{ inputs.postgres && 'postgres:18' || '' }}
env:
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
- pg_socket:/var/run/postgresql
options: >-
--health-cmd "pg_isready -h 127.0.0.1 -U postgres"
--health-interval 2s
--health-timeout 5s
--health-retries 30
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
fetch-depth: 0
- name: Initial setup
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Restore dependency cache
uses: actions/cache/restore@v5
with:
path: |
/opt/cargo/registry
/opt/cargo/git
key: cargo-deps-${{ runner.arch }}-${{ hashFiles('Cargo.lock') }}
restore-keys: cargo-deps-${{ runner.arch }}-
- name: Restore build cache
uses: actions/cache/restore@v5
with:
path: target
key: cargo-build-${{ runner.arch }}-${{ github.sha }}
restore-keys: cargo-build-${{ runner.arch }}-
- name: Test crate with coverage
run: cargo llvm-cov --package "${CRATE}" --lcov --output-path lcov.info
env:
CRATE: ${{ inputs.crate }}
HYPHEN_TEST_DATABASE_URL: ${{ inputs.postgres && 'postgresql://postgres@postgres:5432/postgres' || '' }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: lcov.info
flags: ${{ inputs.crate }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}