]> git.apps.os.sepia.ceph.com Git - fscrypt.git/commitdiff
travis: use multiple build stages
authorJoseph Richey <joerichey94@gmail.com>
Mon, 12 Feb 2018 05:22:53 +0000 (21:22 -0800)
committerJoseph Richey <joerichey94@gmail.com>
Mon, 12 Feb 2018 05:38:13 +0000 (21:38 -0800)
This change rewrites .travis.yml to use many build stages/jobs. This
allows our build to run faster, as almost all jobs run in containers.

Stage 1: Run on all pushes to all branches
  - Job Build: just runs "make" to make sure everything is OK

Stage 2: Run on all PRs and pushes to master
  - Job Lint: Makes sure dep, "make gen", "make format", and "make lint"
              are all happy.
  - Job Build 1: Make sure "go get" and "make" will work. This job will
                 later run unit tests.
  - Job Build 2: Same as Job Build 1, except with another go version.
  - Job Integeration: Run integration tests (needs sudo, so needs VM)

Stage 3: Run on releases (if other stages pass)
  - Job Deploy: Publishes amd64 binaries to GitHub.

.travis.yml
bin/files-changed [new file with mode: 0755]

index 925007d65e32c5d7c74ddaa21fc80ebb54788599..6d0ae57ef8f1510a7d6ed7f1b76a25018a350008 100644 (file)
@@ -1,21 +1,77 @@
 language: go
-sudo: required
-go:
-  - 1.9.x
+sudo: false
 dist: trusty
+go: 1.9.x
 
-addons:
-  apt:
-    sources:
-      - sourceline: 'deb http://en.archive.ubuntu.com/ubuntu/ artful main universe'
-    packages:
-      - libpam0g-dev
-      - e2fsprogs
-      - protobuf-compiler
-      - git # Needed to stop git from getting deleted
+notifications:
+  email: false
 
-install:
-  - make travis-install
+stages:
+  - name: build
+    if: type = push
+  - name: presubmits
+    if: type = pr OR branch = master OR tag IS present
+  - name: deploy
+    if: type = push AND tag IS present
 
-script:
-  - make travis-script
+jobs:
+  include:
+    - stage: build
+      install: skip
+      script: make
+
+    - stage: presubmits
+      env: Generate, Format, and Lint
+      install:
+        - wget -q https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64 -O /tmp/dep
+        - chmod a+x /tmp/dep
+        - make tools
+      script:
+        - /tmp/dep status
+        - make gen
+        - bin/files-changed proto
+        - make format
+        - bin/files-changed format
+        - make lint
+
+    - &build
+      env: Build and Unit Tests
+      install: skip
+      script:
+        - go build github.com/google/fscrypt/cmd/fscrypt
+        - make
+    - <<: *build
+      go: 1.8.x
+
+    - env: Integration Tests
+      sudo: required
+      addons:
+        apt:
+          sources:
+            - sourceline: 'deb http://en.archive.ubuntu.com/ubuntu/ artful main universe'
+          packages:
+            - e2fsprogs
+      install:
+        - go get -u github.com/mattn/goveralls
+        - make test-setup
+      script:
+        - make coverage.out
+        - goveralls -coverprofile=coverage.out -service=travis-ci
+
+    - stage: deploy
+      env: Release Binaries
+      install: skip
+      script: skip
+      before_deploy: make
+      deploy:
+        - provider: releases
+          api_key:
+            secure: TODO
+          file:
+            - bin/fscrypt
+            - bin/pam_fscrypt.so
+          skip_cleanup: true
+          on:
+            repo: google/master
+            branch: master
+            tags: true
diff --git a/bin/files-changed b/bin/files-changed
new file mode 100755 (executable)
index 0000000..3ffbad6
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+# Detect if any files have changed in the git repository. Output an appropriate
+# error message if they have changed.
+
+if [[ -n $(git status -s) ]]; then
+  git diff --minimal HEAD
+  echo
+  echo "**************************************************"
+  case "$1" in
+  "proto")
+    echo "* .pb.go files and .proto files are out of sync. *"
+    echo "*        Run \"make gen\" to generate them.        *"
+    ;;
+  "format")
+    echo "*    C or Go files have incorrect formatting.    *"
+    echo "*         Run \"make format\" to fix them.         *"
+    ;;
+  *)
+    echo "*     Files have changed in this repository.     *"
+    ;;
+  esac
+  echo "**************************************************"
+  git reset HEAD --hard
+  exit 1
+fi
\ No newline at end of file