Browse Source

configure travis ci

Pietro Albini 6 years ago
parent
commit
bd7a814b29
4 changed files with 54 additions and 0 deletions
  1. 15 0
      .travis.yml
  2. 18 0
      ci/check-nightly-version.sh
  3. 9 0
      ci/publish-docker.sh
  4. 12 0
      ci/run.sh

+ 15 - 0
.travis.yml

@@ -0,0 +1,15 @@
+language: rust
+rust: nightly-2019-03-15
+cache:
+  - cargo
+
+script: ci/run.sh
+
+# Publish the Docker image to the infra AWS registry
+before_deploy:
+  - pip install --user awscli
+deploy:
+  provider: script
+  script: sh ci/publish-docker.sh
+  on:
+    branch: master

+ 18 - 0
ci/check-nightly-version.sh

@@ -0,0 +1,18 @@
+#!/bin/bash
+set -euo pipefail
+IFS=$'\n\t'
+
+# Extract the nightly version from all the places we declared it in
+rust_toolchain="$(cat rust-toolchain)"
+travis_yml="$(cat .travis.yml | grep '^rust: ' | head -n 1 | sed -E 's/^rust: (nightly-[0-9]{4}-[0-9]{2}-[0-9]{2})$/\1/')"
+
+# Ensure all the configuration files points to the same nightly
+check() {
+    if [[ "$2" != "${rust_toolchain}" ]]; then
+        echo "error: the nightly version in $1 is different than the one in rust-toolchain!" 1>&2
+        exit 1
+    fi
+}
+check .travis.yml "${travis_yml}"
+
+echo "all the configuration files points to the same nightly!"

+ 9 - 0
ci/publish-docker.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+set -e
+
+ECR_IMAGE="890664054962.dkr.ecr.us-west-1.amazonaws.com/rust-triagebot:latest"
+
+$(aws ecr get-login --no-include-email --region us-west-1)
+
+docker tag rust-triagebot:latest "${ECR_IMAGE}"
+docker push "${ECR_IMAGE}"

+ 12 - 0
ci/run.sh

@@ -0,0 +1,12 @@
+#!/bin/bash
+set -euo pipefail
+IFS=$'\n\t'
+
+rustup component add rustfmt clippy
+
+ci/check-nightly-version.sh
+cargo test
+cargo fmt -- --check
+cargo clippy -- -Dwarnings
+
+docker build -t rust-triagebot .