Split/Refacto Travis job

This commit is contained in:
Fabrice Reix 2020-09-11 10:52:53 +02:00
parent ac058bdae9
commit 7581e1f549
8 changed files with 102 additions and 88 deletions

View File

@ -7,45 +7,41 @@ jobs:
include:
- os: linux
dist: bionic
before_script:
- ci/setup.sh
script:
- ./build.sh
- export PATH="$PWD/target/debug:$PATH"
- integration/integration.sh
- os: linux
dist: bionic
before_script:
- export VERSION=$(grep '^version' Cargo.toml | cut -f2 -d'"')
script:
- ci/man.sh
- ci/release.sh
- ci/create_tarball.sh linux
- ci/deb.sh
deploy:
provider: script
script: ci/deploy.sh
skip_cleanup: true
on:
all_branch: true
tags: true
- os: osx
#cache: cargo
before_install:
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update && brew install libxml2 jq mitmproxy; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get update && sudo apt install python3-pip; fi
before_script:
- rustup component add clippy
- cargo clippy --version
- cargo install cargo-deb
- which python3
- python3 -V
- pip3 install Flask
- cd integration && python3 server.py&
- wget https://snapshots.mitmproxy.org/5.2/mitmproxy-5.2-linux.tar.gz -O - | tar -xz
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then wget https://snapshots.mitmproxy.org/5.2/mitmproxy-5.2-linux.tar.gz -O - | tar -xz; ./mitmdump & fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then mitmdump & fi
- sleep 2
- netstat -an | grep LISTEN | egrep '8000|8080'
- export VERSION=$(grep '^version' Cargo.toml | cut -f2 -d'"')
script:
- ./build.sh
- cargo build --release --verbose
- strip $PWD/target/release/hurl
- strip $PWD/target/release/hurlfmt
- export PATH="$PWD/target/release:$PATH"
- integration/integration.sh
- ci/create_tarballs target/upload "$TRAVIS_OS_NAME"
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then cargo deb && cp target/debian/*.deb target/upload; fi
deploy:
provider: script
script: ci/deploy.sh
skip_cleanup: true
on:
all_branch: true
tags: true
before_script:
- export VERSION=$(grep '^version' Cargo.toml | cut -f2 -d'"')
script:
- ci/man.sh
- ci/release.sh
- ci/create_tarball.sh osx
deploy:
provider: script
script: ci/deploy.sh
skip_cleanup: true
on:
all_branch: true
tags: true

View File

@ -1,20 +0,0 @@
#!/bin/bash
set -e
set -u
VERSION=$1
echo check git tag
TAG=$(git tag --points-at HEAD |tr -d '\n')
if [ "$TAG" == "" ]; then
echo "Tag is not set"
exit 0
fi
if [ "$TAG" != "$VERSION" ]; then
echo "Tag '$TAG' does not match version '$VERSION'"
exit 1
fi
echo tag matches version

16
ci/create_tarball.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
set -e
set -u
os="$1"
package_dir="target/tarball/hurl-$VERSION"
tarball_file="hurl-$VERSION-x86_64-$os.tar.gz"
mkdir -p "$package_dir"
cp target/release/hurl "$package_dir"
cp target/release/hurlfmt "$package_dir"
cp target/man/* "$package_dir"
mkdir -p target/upload
tar cvfz "target/upload/$tarball_file" -C "$(dirname "$package_dir")" "hurl-$VERSION"

View File

@ -1,28 +0,0 @@
#!/bin/bash
set -e
set -u
OUTPUT_DIR="$1"
OS="$2"
RELEASE_DIR=$PWD/target/release
MAN_DIR=$PWD/target/man
VERSION=$(grep '^version' Cargo.toml | cut -f2 -d'"')
PACKAGE_DIR="hurl-$VERSION"
TARBALL_FILE="hurl-$VERSION-x86_64-$OS.tar.gz"
mkdir -p "$OUTPUT_DIR"
echo create tarballs into "$OUTPUT_DIR"
cd "$OUTPUT_DIR"
rm -rf "$PACKAGE_DIR"
mkdir "$PACKAGE_DIR"
cp "$RELEASE_DIR/hurl" "$PACKAGE_DIR"
cp "$RELEASE_DIR/hurlfmt" "$PACKAGE_DIR"
cp "$MAN_DIR"/* "$PACKAGE_DIR"
tar cvfz "$TARBALL_FILE" "$PACKAGE_DIR"
rm -rf "$PACKAGE_DIR"

6
ci/deb.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e
cargo install cargo-deb
cargo deb
cp target/debian/*.deb target/upload

10
ci/man.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
set -e
mkdir -p target/man
cp docs/hurl.1 target/man
cp docs/hurlfmt.1 target/man
gzip target/man/hurl.1
gzip target/man/hurlfmt.1

7
ci/release.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
set -e
cargo build --release --verbose
strip target/release/hurl
strip target/release/hurlfmt

27
ci/setup.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
set -e
#ROOT_DIR=$(pwd)
rustup component add clippy
cargo clippy --version
cargo install cargo-deb
# Python/Flask
sudo apt-get install python3-pip
which python3
python3 -V
which pip3
pip3 install Flask
(cd integration && python3 server.py&)
# Mitmproxy
wget https://snapshots.mitmproxy.org/5.2/mitmproxy-5.2-linux.tar.gz -O - | tar -xz
./mitmdump &
sleep 2
netstat -an | grep LISTEN | grep -E '8000|8080'