Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Commit

Permalink
Update workflows (#29)
Browse files Browse the repository at this point in the history
* Update workflows

* Add check target to test all golang versions

* Fix makefile

* Testing

* Install dockerlint

* Undo tests

* Test permissions

* Exit with code 1 when docker check fails

* Exit with code 1 when docker check fails

* Revert permissions
  • Loading branch information
cedrickring authored Mar 31, 2020
1 parent cbcc2ff commit 98739d9
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 49 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on: pull_request
name: Run checks
jobs:
go-checks:
name: Run go checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Test Go Modules Vendor
uses: ./
env:
IMPORT: cedrickring/golang-action
PROJECT_PATH: ./tests/projects/go_modules_vendored
- name: Test Go Modules
uses: ./
env:
IMPORT: cedrickring/golang-action
PROJECT_PATH: ./tests/projects/go_modules
- name: Test Go Standard
uses: ./
env:
IMPORT: cedrickring/golang-action
PROJECT_PATH: ./tests/projects/go_standard
action-checks:
name: Run action checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install dockerfile_lint
run: sudo npm i -g dockerfile_lint
- name: Lint
run: make lint
- name: Test
run: make test
- name: Docker Build
run: make build
- name: Check all versions
run: make docker-check
26 changes: 12 additions & 14 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
on: push
name: Build on Push
on:
push:
branches:
- master
name: Test build on push
jobs:
testGoDepVendor:
name: Test Go Dep Vendor
go-test:
name: Test go configurations
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Test Go Dep Vendor
uses: ./
env:
IMPORT: cedrickring/golang-action
PROJECT_PATH: ./tests/projects/go_dep_vendored
- name: Test Go Dep
uses: ./
env:
IMPORT: cedrickring/golang-action
PROJECT_PATH: ./tests/projects/go_dep
- name: Test Go Modules Vendor
uses: ./
env:
Expand All @@ -31,6 +24,11 @@ jobs:
env:
IMPORT: cedrickring/golang-action
PROJECT_PATH: ./tests/projects/go_standard
test:
name: Run tests and build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install dockerfile_lint
run: sudo npm i -g dockerfile_lint
- name: Lint
Expand Down
39 changes: 5 additions & 34 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,21 @@
on: release
name: Build and Publish
name: Publish to Docker Hub
jobs:
testGoDepVendor:
name: Test Go Dep Vendor
publish:
name: Publish docker images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Test Go Dep Vendor
uses: ./
env:
IMPORT: cedrickring/golang-action
PROJECT_PATH: ./tests/projects/go_dep_vendored
- name: Test Go Dep
uses: ./
env:
IMPORT: cedrickring/golang-action
PROJECT_PATH: ./tests/projects/go_dep
- name: Test Go Modules Vendor
uses: ./
env:
IMPORT: cedrickring/golang-action
PROJECT_PATH: ./tests/projects/go_modules_vendored
- name: Test Go Modules
uses: ./
env:
IMPORT: cedrickring/golang-action
PROJECT_PATH: ./tests/projects/go_modules
- name: Test Go Standard
uses: ./
env:
IMPORT: cedrickring/golang-action
PROJECT_PATH: ./tests/projects/go_standard
- name: Install dockerfile_lint
run: sudo npm i -g dockerfile_lint
- name: Lint
run: make lint
- name: Test
run: make test
- name: Docker Login
uses: azure/docker-login@v1
with:
password: ${{ secrets.DOCKER_PASSWORD }}
username: ${{ secrets.DOCKER_USERNAME }}
- name: Docker Build
run: make build
- name: Docker Tag
run: make docker-tag
- name: Build
run: make test
- name: Docker Publish
run: make publish
14 changes: 13 additions & 1 deletion docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,19 @@ docker-build: update-docker-go-versions ## Build the top level Dockerfile using
for version in $(GO_VERSIONS) ; do \
docker build $(DOCKER_BUILD_ARG) -t $(IMAGE_NAME) -t $(IMAGE_NAME):$$version go$$version/; \
done


.PHONY: docker-check
docker-check:
for version in $(GO_VERSIONS); do \
cp -r tests/projects/go_standard tests/projects/go_standard_$$version; \
docker run --rm \
-v $(shell pwd)/tests/projects/go_standard_$$version:/github/workspace \
-e GITHUB_REPOSITORY="golang-action" \
-e GITHUB_WORKSPACE="/github/workspace"\
--workdir /github/workspace \
$(IMAGE_NAME):$$version || exit 1; \
done

.PHONY: docker-tag
docker-tag: ## Tag the docker image using the tag script.
docker tag $(IMAGE_NAME):latest $(DOCKER_REPOSITORY)/$(IMAGE_NAME):$(ACTION_VERSION)
Expand Down

0 comments on commit 98739d9

Please sign in to comment.