forked from tembo-io/trunk
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (110 loc) · 3.24 KB
/
cli.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
name: Trunk CLI workflow
defaults:
run:
shell: bash
working-directory: ./cli/
on:
pull_request:
branches:
- main
paths:
- ".github/workflows/cli.yml"
- "cli/**"
- "!cli/README.md"
- "!cli/.gitignore"
push:
branches:
- main
paths:
- ".github/workflows/cli.yml"
- "cli/**"
- "!cli/README.md"
- "!cli/.gitignore"
jobs:
lint:
name: Run linters
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Install minimal nightly with clippy and rustfmt
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
prefix-key: "trunk-cli-lint"
workspaces: |
cli
- name: Cargo format
run: cargo +nightly fmt --check
- name: Clippy
run: cargo clippy
test:
name: Run tests
runs-on:
- self-hosted
- dind
- large-8x8
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
with:
prefix-key: "trunk-cli-functional-test"
workspaces: |
cli
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev postgresql
- name: Run functional tests
run: |
USER=$(whoami)
sudo chown -R $USER $(pg_config --sharedir)
sudo chown -R $USER $(pg_config --pkglibdir)
cargo test -- --nocapture
cargo_publish:
# On a pull request, this is validating that the version
# is not already published to crates.io, and on a push to
# main or release branches, it is publishing if the version
# does not exist, ignoring if the version is already
# published.
name: Cargo publish or validate
runs-on: ubuntu-20.04
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Check out the coredb repo to reuse some actions
uses: actions/checkout@v3
with:
repository: tembo-io/coredb
path: ./coredb
ref: 306f7c3ead394ee041f96d08f6576dc79646a6a2
- name: Determine which flags to use on cargo publish
id: cargo_flags
run: |
set -x
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
if [ "${BRANCH_NAME}" == "main" ]; then
echo "dry_run=false" >> $GITHUB_OUTPUT
echo "fail_if_version_published=false" >> $GITHUB_OUTPUT
else
echo "dry_run=true" >> $GITHUB_OUTPUT
echo "fail_if_version_published=true" >> $GITHUB_OUTPUT
fi
- uses: Swatinem/rust-cache@v2
with:
prefix-key: trunk-cli
workspaces: |
cli
- name: Publish or validate
uses: ./coredb/.github/actions/publish-crate
with:
working-directory: cli
dry-run: ${{ steps.cargo_flags.outputs.dry_run }}
fail-if-version-published: ${{ steps.cargo_flags.outputs.fail_if_version_published }}
cargo-registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}