-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from fsouza/gh-actions
GH Actions, Take 2
- Loading branch information
Showing
10 changed files
with
182 additions
and
452 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.