-
-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (161 loc) · 6.19 KB
/
ci.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
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
#############################################################
# WARNING: automatically generated file, DO NOT CHANGE! #
#############################################################
# This file was automatically generated by the expand-yaml-anchors tool. The
# source file that generated this one is:
#
# ci/github-actions/ci.yaml
#
# Once you make changes to that file you need to run:
#
# cargo run --manifest-path tools/expand-yaml-anchors/Cargo.toml -- generate $PWD
#
# The CI build will fail if the tool is not run after changes to this file.
---
name: CI
"on":
push:
branches:
- main
- staging
- trying
pull_request:
branches:
- main
env:
CARGO_TERM_COLORS: always
jobs:
coverage:
name: Rust Coverage
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-C link-dead-code"
DATABASE_URL: "postgres://postgres:postgres@localhost/noted"
MIGRATION_DIRECTORY: db/migrations
DIESEL_CONFIG_FILE: db/diesel.toml
steps:
- name: Checkout sources
uses: actions/checkout@v2
- with:
toolchain: nightly
profile: minimal
components: "clippy, rustfmt"
override: true
name: Install toolchain
uses: actions-rs/toolchain@v1
- uses: actions/cache@v2
with:
path: "~/.cargo/bin/\n"
key: "${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-cov"
- name: Install diesel_cli
run: "which diesel || cargo install diesel_cli --no-default-features --features postgres\n"
- name: Install postgres
run: "sudo apt-get update\nsudo apt-get install -y libpq-dev postgresql\necho \"host all all 127.0.0.1/32 md5\" > sudo tee -a /etc/postgresql/10/main/pg_hba.conf\nsudo service postgresql restart && sleep 3\nsudo -u postgres psql -c \"ALTER USER postgres PASSWORD 'postgres';\"\nsudo service postgresql restart && sleep 3\n"
- name: Create database
run: "sudo -u postgres psql -c 'create database noted;' -U postgres\ndiesel migration run --locked-schema\n"
- name: Clean target
uses: actions-rs/cargo@v1
with:
command: clean
- name: Run cargo test
uses: actions-rs/cargo@v1
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"
RUSTDOCFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests"
with:
command: test
args: "--all --all-features --no-fail-fast"
- name: Pre-Install grcov
run: "which grcov || cargo install grcov\n"
- name: Run grcov
id: coverage
uses: actions-rs/[email protected]
- name: Upload Codecov
uses: codecov/codecov-action@v2
with:
token: "${{ secrets.CODECOV_TOKEN }}"
files: "${{ steps.coverage.outputs.report }}"
fail_ci_if_error: true
verbose: true
flags: backend
check:
name: Rust Build/Test/Lint
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-C link-dead-code"
DATABASE_URL: "postgres://postgres:postgres@localhost/noted"
MIGRATION_DIRECTORY: db/migrations
DIESEL_CONFIG_FILE: db/diesel.toml
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.56.1
components: "clippy, rustfmt"
override: true
- uses: actions/cache@v2
with:
path: "~/.cargo/bin/\n~/.cargo/registry/index/\n~/.cargo/registry/cache/\n~/.cargo/git/db/\ntarget/\n"
key: "${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}"
- name: Install diesel_cli
run: "which diesel || cargo install diesel_cli --no-default-features --features postgres\n"
- name: Install postgres
run: "sudo apt-get update\nsudo apt-get install -y libpq-dev postgresql\necho \"host all all 127.0.0.1/32 md5\" > sudo tee -a /etc/postgresql/10/main/pg_hba.conf\nsudo service postgresql restart && sleep 3\nsudo -u postgres psql -c \"ALTER USER postgres PASSWORD 'postgres';\"\nsudo service postgresql restart && sleep 3\n"
- name: Create database
run: "sudo -u postgres psql -c 'create database noted;' -U postgres\ndiesel migration run --locked-schema\n"
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: "--all -- --check"
- name: Run clippy action to produce annotations
if: "github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]'"
uses: actions-rs/clippy-check@v1
with:
token: "${{ secrets.GITHUB_TOKEN }}"
args: "--all-features"
- name: Run clippy manually without annotations
if: "github.event.pull_request.head.repo.full_name != github.repository || github.actor == 'dependabot[bot]'"
uses: actions-rs/cargo@v1
with:
command: clippy
args: "--all-targets -- -D warnings"
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: "--all"
node-ci:
name: Node Build/Test/Lint
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: "16"
- name: Build Cache
uses: actions/cache@v2
with:
path: ~/.npm
key: "${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}"
restore-keys: "${{ runner.os }}-node-\n"
- name: Build Package
run: yarn install --frozen-lockfile && yarn build
- name: Lint
run: yarn lint
- name: Test
run: yarn test
- name: Upload Codecov
uses: codecov/codecov-action@v2
with:
token: "${{ secrets.CODECOV_TOKEN }}"
files: coverage/coverage-final.json
flags: ui
fail_ci_if_error: true
verbose: true