-
Notifications
You must be signed in to change notification settings - Fork 28
Enhance workflow #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
crazy-max
wants to merge
1
commit into
psampaz:master
Choose a base branch
from
crazy-max:enhance-workflow
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Enhance workflow #51
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,6 @@ | ||
/.idea | ||
/*.iml | ||
|
||
/dist | ||
/coverage.txt | ||
/go-mod-outdated |
This file contains hidden or 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 |
---|---|---|
@@ -1,83 +1,160 @@ | ||
name: CI Workflow | ||
on: [pull_request] | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
|
||
jobs: | ||
golangci: | ||
validate: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
go-version: [1.16.x] | ||
platform: [ubuntu-latest] | ||
name: golangci-lint | ||
runs-on: ${{ matrix.platform }} | ||
target: | ||
- lint | ||
- vendor-validate | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
- uses: actions/setup-go@v2 | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
- | ||
name: Validate | ||
uses: docker/bake-action@v1 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- run: | | ||
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.37.1 golangci-lint run -v | ||
docker: | ||
strategy: | ||
matrix: | ||
go-version: [1.16.x] | ||
platform: [ubuntu-latest] | ||
name: docker | ||
runs-on: ${{ matrix.platform }} | ||
targets: ${{ matrix.target }} | ||
|
||
coverage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
- uses: actions/setup-go@v2 | ||
fetch-depth: 0 | ||
- | ||
name: Test | ||
uses: docker/bake-action@v1 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- run: | | ||
docker build -t psampaz/go-mod-outdated . | ||
go list -u -m -json all | docker run --rm -i psampaz/go-mod-outdated | ||
tests: | ||
targets: test | ||
- | ||
name: Upload coverage | ||
uses: codecov/codecov-action@v2 | ||
with: | ||
file: ./coverage.txt | ||
|
||
e2e: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
go-version: [1.14.x, 1.15.x, 1.16.x] | ||
platform: [ubuntu-latest, macos-latest] | ||
name: tests | ||
runs-on: ${{ matrix.platform }} | ||
os: | ||
- ubuntu-latest | ||
- macos-latest | ||
go-version: | ||
- 1.14 | ||
- 1.15 | ||
- 1.16 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
- uses: actions/setup-go@v2 | ||
- | ||
name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- run: | | ||
- | ||
name: Test | ||
run: | | ||
go get github.com/mfridman/tparse | ||
go test -v -race -cover -json ./... | $(go env GOPATH)/bin/tparse -all | ||
- run: | | ||
- | ||
name: Integration | ||
run: | | ||
go install | ||
mkdir hugo | ||
mkdir hugo | ||
cp internal/runner/testdata/hugo_0_53_go.mod hugo/go.mod | ||
cd hugo | ||
go list -u -m -json all | $(go env GOPATH)/bin/go-mod-outdated | ||
coverage: | ||
strategy: | ||
matrix: | ||
go-version: [1.16.x] | ||
platform: [ubuntu-latest] | ||
name: coverage | ||
runs-on: ${{ matrix.platform }} | ||
go list -u -m -json all | $(go env GOPATH)/bin/go-mod-outdated | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- validate | ||
- coverage | ||
env: | ||
DOCKERHUB_SLUG: psampaz/go-mod-outdated | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
- uses: actions/setup-go@v2 | ||
fetch-depth: 0 | ||
- | ||
name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- run: | | ||
go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic ./... | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
images: | | ||
${{ env.DOCKERHUB_SLUG }} | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=ref,event=pr | ||
type=edge | ||
labels: | | ||
org.opencontainers.image.title=go-mod-outdated | ||
org.opencontainers.image.description=Find outdated dependencies of your Go projects | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- | ||
name: Login to DockerHub | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v1 | ||
with: | ||
token: ${{secrets.CODECOV_TOKEN}} | ||
file: ./coverage.txt | ||
flags: unittests | ||
name: codecov-umbrella | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- | ||
name: Build artifacts | ||
uses: docker/bake-action@v1 | ||
with: | ||
targets: artifact-all | ||
- | ||
name: Move artifacts | ||
run: | | ||
mv ./dist/**/* ./dist/ | ||
- | ||
name: Upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: go-mod-outdated | ||
path: ./dist/* | ||
if-no-files-found: error | ||
- | ||
name: Build image | ||
uses: docker/bake-action@v1 | ||
with: | ||
files: | | ||
./docker-bake.hcl | ||
${{ steps.meta.outputs.bake-file }} | ||
targets: image-all | ||
push: ${{ github.event_name != 'pull_request' }} | ||
- | ||
name: GitHub Release | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
draft: true | ||
files: | | ||
dist/*.tar.gz | ||
dist/*.zip | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or 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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
.idea | ||
vendor | ||
go-mod-outdated | ||
/.idea | ||
/*.iml | ||
|
||
/dist | ||
/coverage.txt | ||
/go-mod-outdated |
This file contains hidden or 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 |
---|---|---|
@@ -1,10 +1,33 @@ | ||
FROM golang:1.16.3-alpine3.13 | ||
# syntax=docker/dockerfile:1.3 | ||
ARG GO_VERSION | ||
|
||
FROM --platform=$BUILDPLATFORM crazymax/goreleaser-xx:latest AS goreleaser-xx | ||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS base | ||
RUN apk add --no-cache git | ||
WORKDIR /home | ||
COPY ./ . | ||
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -o go-mod-outdated . | ||
COPY --from=goreleaser-xx / / | ||
WORKDIR /src | ||
|
||
FROM base AS build | ||
ARG TARGETPLATFORM | ||
ARG GIT_REF | ||
RUN --mount=type=bind,target=/src,rw \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
--mount=target=/go/pkg/mod,type=cache \ | ||
goreleaser-xx --debug \ | ||
--name "go-mod-outdated" \ | ||
--dist "/out" \ | ||
--hooks="go mod tidy" \ | ||
--hooks="go mod download" \ | ||
--ldflags="-s -w" \ | ||
--files="CHANGELOG.md" \ | ||
--files="LICENSE" \ | ||
--files="README.md" | ||
|
||
FROM scratch AS artifacts | ||
COPY --from=build /out/*.tar.gz / | ||
COPY --from=build /out/*.zip / | ||
|
||
FROM scratch | ||
WORKDIR /home/ | ||
COPY --from=0 /home/go-mod-outdated . | ||
COPY --from=build /usr/local/bin/go-mod-outdated . | ||
ENTRYPOINT ["./go-mod-outdated"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DOCKERHUB_USERNAME
,DOCKERHUB_TOKEN
.