Skip to content

Commit

Permalink
Development & CI Improvements (#27)
Browse files Browse the repository at this point in the history
* Development & CI Improvements

* fix build on Windows

* Update Dockerfile

* Update dev-env.Dockerfile

* fix indent

* rename

* refactor env command

* upgrade go in ci

* Update image.yml

* split docs ci into 2 workflows

* fix

* Revert "fix"

This reverts commit ec4833d.

* Revert "split docs ci into 2 workflows"

This reverts commit bb317bc.

* only build docs when necessary

* fix badges

Co-authored-by: Ofek Lev <ofekmeister@gmail.com>
  • Loading branch information
maennchen and ofek authored Apr 25, 2020
1 parent 4494169 commit b06f8f6
Show file tree
Hide file tree
Showing 24 changed files with 544 additions and 325 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Documentation

on:
push:
paths:
- docs/**
- .github/workflows/docs.yml
- tasks/docs.py
- mkdocs.yml
- tox.ini
pull_request:
paths:
- docs/**
- .github/workflows/docs.yml
- tasks/docs.py
- mkdocs.yml
- tox.ini

jobs:
build:
name: Build Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: "3.8"

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
python -m pip install --upgrade -r requirements.txt
- name: Build docs
run: |
invoke docs.build
- uses: actions/upload-artifact@v1
with:
name: Documentation
path: site

publish:
name: Publish Docs
runs-on: ubuntu-latest
# Only publish master
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs:
- build
steps:
- uses: actions/download-artifact@v1
with:
name: Documentation
path: site

- name: Publish generated content to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
142 changes: 142 additions & 0 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Image

on: [push, pull_request]

jobs:
build_driver:
name: Build Driver
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 50

- name: Fetch Tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.13.6

- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: "3.8"

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
python -m pip install --upgrade -r requirements.txt
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build Driver
run: |
invoke build --release
- uses: actions/upload-artifact@v1
with:
name: Driver
path: bin

build_container:
name: Build Docker Container
runs-on: ubuntu-latest
needs:
- build_driver
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 50

- name: Fetch Tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Install Go
uses: actions/setup-go@v1
with:
go-version: 1.13.3

- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: "3.8"

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
python -m pip install --upgrade -r requirements.txt
- uses: actions/download-artifact@v1
with:
name: Driver
path: bin

- name: Make Driver executable
run: "chmod +x bin/*"

- name: Build Docker Container
run: |
invoke image --release --compress
- name: Package Container
run: |
TAG=$(git describe --long --tags --match='v*' --dirty)
docker save -o ./container.tar.gz ofekmeister/csi-gcs:$TAG
- uses: actions/upload-artifact@v1
with:
name: Container
path: ./container.tar.gz

publish_container:
name: Publish Container
runs-on: ubuntu-latest
needs:
- build_container
# Only Publish Images from our repository, not for MR
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 50

- name: Fetch Tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: "3.8"

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
python -m pip install --upgrade -r requirements.txt
- uses: actions/download-artifact@v1
with:
name: Container
path: .

- name: Import Container
run: |
TAG=$(git describe --long --tags --match='v*' --dirty)
docker import ./container.tar.gz ofekmeister/csi-gcs:$TAG
- name: Login to Docker.io
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
env:
DOCKER_USERNAME: ${{ secrets.DockerUsername }}
DOCKER_PASSWORD: ${{ secrets.DockerPassword }}

- name: Publish Docker Container
run: |
invoke image.deploy
42 changes: 0 additions & 42 deletions .github/workflows/publish.yml

This file was deleted.

79 changes: 35 additions & 44 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,18 @@
name: Test

on:
push:
branches:
- master
pull_request:
branches:
- master
on: [push, pull_request]

jobs:
build:
name: Build Docker Image
test_unit:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v1
- name: Install Go
uses: actions/setup-go@v2
with:
python-version: "3.8"

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
python -m pip install --upgrade -r requirements.txt
- name: Install Test Secrets
shell: bash
env:
TEST_SECRETS: ${{ secrets.TestSecrets }}
run: |
echo "$TEST_SECRETS" > test/secret.yaml
- name: Build image
run: |
invoke image
docs:
name: Generate Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
go-version: 1.13.6

- name: Set up Python 3.8
uses: actions/setup-python@v1
Expand All @@ -52,21 +24,31 @@ jobs:
python -m pip install --upgrade pip setuptools
python -m pip install --upgrade -r requirements.txt
- name: Build docs
run: |
invoke docs.build
- uses: actions/upload-artifact@v1
- uses: actions/cache@v1
with:
name: Documentation
path: site
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-test_unit-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-test_unit-
${{ runner.os }}-go-
- name: Run Tests
run: |
invoke test.unit
test_sanity:
name: Sanity Test
name: Test Sanity
runs-on: ubuntu-latest
# Secrets are only available for Push
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2

- name: Install Go
uses: actions/setup-go@v1
with:
go-version: 1.13.3

- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
Expand All @@ -77,15 +59,24 @@ jobs:
python -m pip install --upgrade pip setuptools
python -m pip install --upgrade -r requirements.txt
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-test_sanity-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-test_sanity-
${{ runner.os }}-go-
- name: Install Test Secrets
shell: bash
env:
TEST_SECRETS: ${{ secrets.TestSecrets }}
run: |
echo "$TEST_SECRETS" > test/secret.yaml
- name: Sanity Test
- name: Run Tests
# TODO: Remove when Sanity Tests are fixed
# https://github.com/ofek/csi-gcs/issues/15
continue-on-error: true
run: |
invoke test.sanity
invoke docker -c "invoke test.sanity"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@
# Test Service Account
/service-account.json
/test/secret.yaml

# Artifacts
/bin/*
!/bin/.gitkeep
Loading

0 comments on commit b06f8f6

Please sign in to comment.