-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
105 lines (94 loc) · 2.86 KB
/
.travis.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
language: rust
env:
global:
- BINARY_NAME=terraform-zap
- REPO_USERNAME=guangie88
- REPO_NAME=terraform-zap
matrix:
include:
- services: docker
env:
- LINT=true
- PUBLISH=true
- services: docker
env:
- ARTIFACT=true
- ARTIFACTS_DIR=./artifacts
- services: docker
env:
- COVERAGE=true
- rust: stable
sudo: false
- rust: beta
sudo: false
- rust: nightly
sudo: false
fast_finish: true
before_script:
- set -e
- |
if [ "$LINT" = "true" ]; then
docker-compose -f docker-compose.lint-test.yml build lint-test
elif [ "$ARTIFACT" = "true" ]; then
echo "Artifact not dealing with 'before_script'"
elif [ "$COVERAGE" = "true" ]; then
echo "Coverage not dealing with 'before_script'"
else
cargo test --all --no-run --verbose
fi
script:
- |
if [ "$LINT" = "true" ]; then
docker-compose -f docker-compose.lint-test.yml run lint-test
elif [ "$ARTIFACT" = "true" ]; then
docker-compose -f docker-compose.build.yml run -u $UID:`id -g` build
mkdir $ARTIFACTS_DIR
cp ./target/x86_64-unknown-linux-musl/release/$BINARY_NAME $ARTIFACTS_DIR
elif [ "$COVERAGE" = "true" ]; then
echo "Coverage not dealing with 'script'"
else
cargo doc --all
cargo test --all --verbose
fi
after_success:
- |
if [ "$PUBLISH" = "true" ]; then
# publish when this is a new tag
cargo login "$CRATES_TOKEN"
if [ -n "$TRAVIS_TAG" ]; then
CARGO_PUBLISH_FLAGS=
else
CARGO_PUBLISH_FLAGS="--dry-run --verbose"
fi
# publish all self dependency libraries first
cd ignore-lib
cargo publish ${CARGO_PUBLISH_FLAGS}
cd ..
# then publish binary
cargo publish ${CARGO_PUBLISH_FLAGS}
elif [ "$ARTIFACT" = "true" ] && [ -n "$TRAVIS_TAG" ]; then
# upload binary artifact when this is a new tag
# this needs to be jq processed to extract out the `id` value
TAG_ID=$(curl -X GET \
-H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$REPO_USERNAME/$REPO_NAME/releases" \
| jq -r '.[] | select(.tag_name == "'$TRAVIS_TAG'").id')
# formulate zip
ZIP_SUFFIX=`uname -s | tr '[:upper:]' '[:lower:]'`-`uname -i`
ZIP_FILE=$BINARY_NAME-$TRAVIS_TAG-$ZIP_SUFFIX.zip
zip -j $ZIP_FILE "$ARTIFACTS_DIR/$BINARY_NAME"
curl -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/zip" \
--upload-file $ZIP_FILE \
"https://uploads.github.com/repos/$REPO_USERNAME/$REPO_NAME/releases/$TAG_ID/assets?name=$ZIP_FILE"
elif [ "$COVERAGE" = "true" ] && [ -z "$TRAVIS_TAG" ]; then
docker run --security-opt seccomp=unconfined -v "$PWD:/volume" \
guangie88/ubuntu-cargo-tarpaulin:xenial-stable "
cargo tarpaulin --all --out Xml \
&& bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN"
fi
branches:
only:
- master
- /^v\d+\.\d+\.\d+(-\S*)?$/