Skip to content

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
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/.idea
/*.iml

/dist
/coverage.txt
/go-mod-outdated
193 changes: 135 additions & 58 deletions .github/workflows/ci.yml
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 }}
Comment on lines +123 to +124
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Before merging:

-
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 }}
9 changes: 6 additions & 3 deletions .gitignore
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
33 changes: 28 additions & 5 deletions Dockerfile
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"]
Loading