Skip to content

Commit

Permalink
Merge pull request #69 from fsouza/gh-actions
Browse files Browse the repository at this point in the history
GH Actions, Take 2
  • Loading branch information
fsouza authored Aug 24, 2019
2 parents 5dc4771 + 12f159a commit 8887080
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 452 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Lint, Test & Publish
on:
push:
branches:
- master

pull_request:
branches:
- master

jobs:
lint-and-test:
strategy:
matrix:
go_version:
- 1.11.13
- 1.12.9
- 1.13rc1

name: lint-and-test (go ${{ matrix.go_version }})
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v1
id: go
with:
version: ${{ matrix.go_version }}

- uses: actions/checkout@master

- name: go-mod-download
run: go mod download
env:
GOPROXY: https://proxy.golang.org

- name: run-linter
uses: docker://golangci/golangci-lint
env:
GOROOT: /usr/local/go
with:
entrypoint: golangci-lint
args: run --enable-all -D errcheck -D lll -D dupl -D gochecknoglobals -D unparam --deadline 5m ./...

- name: run-tests
run: go test -race -vet all -mod readonly ./...

build:
name: build-and-publish
runs-on: ubuntu-latest
needs: lint-and-test
steps:
- uses: actions/checkout@master

- uses: actions/setup-go@v1
id: go
with:
version: 1.13rc1

- name: go-build
run: go build -o fake-gcs-server -mod readonly
env:
CGO_ENABLED: 0
GOPROXY: https://proxy.golang.org,https://gocenter.io,direct

- name: sanity-check
uses: docker://alpine
with:
entrypoint: sh
args: -c "./fake-gcs-server -h"

- name: test-python-example
uses: docker://python:3
with:
entrypoint: bash
args: ci/run-python-example.sh

- name: docker-publish
uses: docker://docker
env:
DOCKER_USERNAME: ${{ secrets.docker_username }}
DOCKER_PASSWORD: ${{ secrets.docker_password }}
with:
entrypoint: sh
args: ci/docker-build.sh
18 changes: 18 additions & 0 deletions .github/workflows/docker-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test Dockerfiles
on:
pull_request:
branches:
- master
paths:
- Dockerfile
jobs:
test-root-dockerfile:
name: test root dockerfile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: test Dockerfile
uses: docker://docker
with:
entrypoint: docker
args: build .
14 changes: 14 additions & 0 deletions .github/workflows/goreleaser-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Test goreleaser
on:
pull_request:
paths:
- .goreleaser.yml
jobs:
test-goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- uses: docker://goreleaser/goreleaser
with:
args: release --snapshot
17 changes: 17 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: goreleaser
on:
create:
ref_type: tag

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- uses: docker://goreleaser/goreleaser
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
entrypoint: bash
args: -c "git fetch --tags && goreleaser release"
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# fake-gcs-server

[![Build Status](https://cloud.drone.io/api/badges/fsouza/fake-gcs-server/status.svg)](https://cloud.drone.io/fsouza/fake-gcs-server)
[![GoDoc](https://img.shields.io/badge/api-Godoc-blue.svg?style=flat-square)](https://godoc.org/github.com/fsouza/fake-gcs-server/fakestorage)

fake-gcs-server provides an emulator for Google Cloud Storage API. It can be
Expand Down
File renamed without changes.
39 changes: 39 additions & 0 deletions ci/docker-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2019 Francisco Souza. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

IMAGE_NAME=fsouza/fake-gcs-server

function pick_tag() {
tag=latest
if [ "${GITHUB_HEAD_REF##refs/tags/}" != "${GITHUB_HEAD_REF}" ]; then
tag=${GITHUB_HEAD_REF##refs/tags}
fi
echo $tag
}

function additional_tags() {
original_tag=$1
if echo "$original_tag" | grep -q '^v\d\+\.\d\+\.\d\+$'; then
filtered=${original_tag#v}
tags="${filtered} ${filtered%.*} ${filtered%%.*}"

for tag in $tags; do
docker tag ${IMAGE_NAME}:${original_tag} ${IMAGE_NAME}:${tag}
done
fi
}

tag=$(pick_tag)
docker build -t "${IMAGE_NAME}:${tag}" -f ci/Dockerfile .
additional_tags "${tag}"

if [ "${GITHUB_EVENT_NAME}" = "push" ]; then
docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}"
docker push ${IMAGE_NAME}
fi

docker system prune -af

# sanity check
docker run "${IMAGE_NAME}:${tag}" -h
11 changes: 11 additions & 0 deletions ci/run-python-example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2019 Francisco Souza. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

./fake-gcs-server -backend memory -data $PWD/examples/data &

EXTERNAL_URL=https://localhost:4443
PUBLIC_HOST=https://localhost:4443

pip install -r examples/python/requirements.txt
python examples/python/python.py
159 changes: 0 additions & 159 deletions drone/.drone.jsonnet

This file was deleted.

Loading

0 comments on commit 8887080

Please sign in to comment.