From 8fe3403de02a192b67725fc2889b7cf9b95c2855 Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Thu, 5 Sep 2019 13:08:48 -0400 Subject: [PATCH] Continuous integration (#2) * Add CI workflow similar to other zebra * Bump cache TTL to 24hours * Expand image name to include full repo owner/repo-name/branch-name * Force to lowercase because google container registry demands it This may not be universally shell compatible * Use bash as gcloud action container entrypoint --- .github/workflows/main.yml | 24 ++++++++++++++++++++++++ Dockerfile | 22 ++++++++++++++++++++++ cloudbuild.yaml | 11 +++++++++++ 3 files changed, 57 insertions(+) create mode 100644 .github/workflows/main.yml create mode 100644 Dockerfile create mode 100644 cloudbuild.yaml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..4ce236ef7 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,24 @@ +name: CI + +on: [push] + +jobs: + + build: + name: Google Cloud Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - run: + - name: Authenticate w/ Google Cloud + uses: actions/gcloud/auth@master + env: + GCLOUD_AUTH: ${{ secrets.GCLOUD_AUTH }} + - name: Build, Test, Push to GCR + uses: actions/gcloud/cli@master + with: + entrypoint: bash + args: | + -l -c "BRANCH_NAME=$GITHUB_REPOSITORY/$(expr $GITHUB_REF : '.*/\(.*\)') && \ + BRANCH_NAME=${BRANCH_NAME,,} && \ + gcloud builds submit . --config cloudbuild.yaml --project zealous-zebra --substitutions BRANCH_NAME=$BRANCH_NAME" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..4a70790cd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM rust:stretch as base + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + make cmake g++ gcc + +RUN mkdir /zebra +WORKDIR /zebra + +ENV RUST_BACKTRACE 1 +ENV CARGO_HOME /zebra/.cargo/ + +# Copy local code to the container image. +# Assumes that we are in the git repo. + +COPY . . + +RUN cargo fetch --verbose + +COPY . . + +RUN rustc -V; cargo -V; rustup -V; cargo test --all && cargo build --release diff --git a/cloudbuild.yaml b/cloudbuild.yaml new file mode 100644 index 000000000..f531a90a9 --- /dev/null +++ b/cloudbuild.yaml @@ -0,0 +1,11 @@ +steps: +- name: 'gcr.io/kaniko-project/executor:latest' + args: + - --destination=gcr.io/$PROJECT_ID/$BRANCH_NAME + - --cache=true + - --cache-ttl=24h + +options: + machineType: 'N1_HIGHCPU_32' + +timeout: 3600s # One hour for all steps.