-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.omni.yaml
134 lines (112 loc) · 3.98 KB
/
.omni.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
up:
- rust:
upgrade: true
- node: auto
- bats: 1
- github-releases:
quarylabs/sqruff: 0.21.0
commands:
create-tag:
desc: Create a new version tag for omni
run: |
set -e
# Do not create a new tag if the current version is tagged already
current_tag=$(git describe --tags --exact-match --match 'v*' 2>/dev/null || true)
if [[ -n "$current_tag" ]]; then
echo "Current commit is already tagged: $current_tag"
exit 1
fi
# We are using CalVer for versioning, so let's generate the tag
# prefix; we also do not want the month to be 0-padded
tag_prefix="v$(date +'%Y.%-m')"
# Now go over the digits from 0 to find the first available digit
# for a version tag
idx=0
while git describe --tags "$tag_prefix.$idx" &>/dev/null; do
idx=$((idx + 1))
done
# The new tag is the first available digit
new_tag="$tag_prefix.$idx"
# Find the last tag by considering the highest version using `sort -V`
last_tag=$(git tag -l "v*" | sort -V | tail -n 1)
# Generate the annotation message using git log
changelog=$(git log --pretty=format:"- %s (%an)" "$last_tag"..HEAD)
# Create the annotated tag with the generated message
git tag -a "$new_tag" -m "$changelog"
echo "Created tag: $new_tag"
website-dev:
desc: |
Starts a local development server for the website
This opens up a browser window once the server is started.
Most changes are reflected live without having to restart the server.
dir: website
run: |
yarn start
cargo-package:
desc: Runs cargo package after overriding the version
run: |
# Check if git is dirty
[ -z "$(git status --short 2>/dev/null)" ] || {
echo "Repository dirty. Please stash all before running."
exit 1
}
# Get version
OMNI_RELEASE_VERSION=$(git describe --tags --broken --dirty --match v*)
if [ -z "$OMNI_RELEASE_VERSION" ]; then
OMNI_RELEASE_VERSION=0.0.0-$(git describe --tags --always --broken --dirty --match v*)
fi
OMNI_RELEASE_VERSION=${OMNI_RELEASE_VERSION#v}
export OMNI_RELEASE_VERSION
# Override Cargo.toml version entry
sed -i 's/^version = "0\.0\.0-git"$/version = "'"${OMNI_RELEASE_VERSION}"'"/' Cargo.toml
# Run Cargo package
cargo package --allow-dirty
# Reset Cargo.toml
git checkout Cargo.toml
lint:
desc: Runs the linter
aliases:
- clippy
run: |
# cargo fmt -- --check
cargo clippy --all-features
test:
desc: Runs the tests
run: |
set -e
cargo test
GENERATE_FIXTURES=false bats tests/
subcommands:
generate:
desc: Generates the fixtures for the tests
run: |
GENERATE_FIXTURES=true bats --filter-tags generate tests/ "$@"
renumber:
desc: Renumber the bats tests
run: |
set -e
find tests/ -type f -name '*.bats' | while IFS= read -r file; do
basename=$(basename "$file" .bats)
prefix=${basename#test_}
# Count total number of tests
total_tests=$(grep -c '^@test "' "$file")
digits=${#total_tests}
awk -v prefix="$prefix" -v digits="$digits" '{
if ($0 ~ /^@test "/) {
# Remove any existing counter in square brackets
sub(/^@test "(\[[^]]*\] )?/, "")
# Add the new counter with zero-padding
printf "@test \"[%s=%0*d] %s\n", prefix, digits, counter, $0
counter++
} else {
print
}
}' counter=1 "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
done
fix:
desc: Fixes the code
run: |
set -e
cargo fix --all-features --color always --allow-dirty
cargo clippy --fix --all-features --color always --allow-dirty
cargo fmt