-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile.toml
125 lines (108 loc) · 2.89 KB
/
Makefile.toml
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
[config]
default_to_workspace = false
[env]
CARGO_TERM_COLOR = "always"
LINT_COMMIT_MSG_FROM_STDIN = "cargo bin conventional_commits_linter --allow-angular-type-only --from-stdin"
[tasks.pre-commit]
env = { RUSTFLAGS = "--deny warnings" }
run_task = { name = ["test", "clippy", "doc", "check_fmt"], parallel = true }
[tasks.ci_main]
env = { RUSTFLAGS = "--deny warnings" }
run_task = { name = ["test", "clippy", "doc", "check_fmt", "lint_pr_commit_msgs"], parallel = true }
[tasks.ci_post]
run_task = { name = ["no_untracked", "no_modified", "release"] }
[tasks.ci]
run_task = { name = ["ci_main", "ci_post"] }
[tasks.test]
command = "cargo"
args = ["test"]
[tasks.clippy]
command = "cargo"
args = ["clippy", "--all-targets"]
[tasks.doc]
command = "cargo"
args = ["doc"]
[tasks.check_fmt]
command = "cargo"
args = ["fmt", "--check"]
[tasks.lint_commit_msg_from_stdin]
script = '''
#!/usr/bin/env bash
set -euxo pipefail
$LINT_COMMIT_MSG_FROM_STDIN
'''
[tasks.lint_pr_commit_msgs]
condition = { env_true = ["GITHUB_BASE_REF"] }
script = '''
#!/usr/bin/env bash
set -euxo pipefail
# workaround for https://gitlab.com/DeveloperC/conventional_commits_linter/-/issues/1
commits=$(git rev-list --skip=1 origin/$GITHUB_BASE_REF..HEAD)
exit_code=0
for commit in $commits; do
git show --no-patch --format=%B $commit | \
$LINT_COMMIT_MSG_FROM_STDIN || \
exit_code=1
done
exit $exit_code
'''
[tasks.table_of_contents]
script = '''
#!/usr/bin/env bash
set -euxo pipefail
toc=$(cargo bin md-toc --header "# Table of contents" README.md | grep --invert-match --fixed-strings '1. [Table of contents]')
MARKER='<!-- TOC -->'
cargo bin sd "$MARKER[\S\s]*$MARKER" $"$MARKER$toc\n$MARKER" README.md
'''
[tasks.no_modified]
script = '''
#!/usr/bin/env bash
set -euxo pipefail
if ! git diff --exit-code; then
echo "modified files detected"
exit 1
fi
'''
[tasks.no_untracked]
script = '''
#!/usr/bin/env bash
set -euxo pipefail
if [[ `git ls-files --exclude-standard --others` ]]; then
echo "untracked files detected"
exit 1
fi
'''
[tasks.release]
condition = { env = { "GITHUB_REF_TYPE" = "branch", "GITHUB_REF_NAME" = "master" } }
script = '''
#!/usr/bin/env bash
set -euxo pipefail
npm install --global \
semantic-release@19 \
@semantic-release/exec@6 \
@semantic-release/changelog@6 \
@semantic-release/git@10 \
conventional-changelog-conventionalcommits@5
semantic-release
'''
[tasks.publish_crates]
script = '''
#!/usr/bin/env bash
set -euxo pipefail
cargo publish --package michie-macro
attempts=0
while [ $attempts -lt 90 ]; do
latest_version=$( \
wget --quiet --output-document - 'https://raw.githubusercontent.com/rust-lang/crates.io-index/master/mi/ch/michie-macro' \
| tail --lines 1 \
| cargo bin jql '"vers"' \
)
if [ $latest_version == "\"$1\"" ]; then
cargo publish --package michie
exit 0
fi
sleep 10
attempts=$((attempts + 1))
done
exit 1
'''