Skip to content

Commit

Permalink
Merge pull request #5 from go-vela/workflows
Browse files Browse the repository at this point in the history
chore: add workflows, clean repo
  • Loading branch information
kaymckay authored Mar 10, 2022
2 parents a758fad + 1401cde commit f7c920f
Show file tree
Hide file tree
Showing 21 changed files with 379 additions and 137 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# name of the action
name: build

# trigger on pull_request or push events
on:
pull_request:
push:

# pipeline to execute
jobs:
build:
runs-on: ubuntu-latest
container:
image: golang:1.17
steps:
- name: clone
uses: actions/checkout@v2

- name: build
run: |
make build
67 changes: 67 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '32 7 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
42 changes: 42 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# name of the action
name: prerelease

# trigger on push events with `v*` in tag
on:
push:
tags:
- "v*"

# pipeline to execute
jobs:
prerelease:
runs-on: ubuntu-latest
container:
image: golang:1.17
steps:
- name: clone
uses: actions/checkout@v2
with:
# ensures we fetch tag history for the repository
fetch-depth: 0

- name: setup
run: |
# setup git tag in Actions environment
echo "GITHUB_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: build
env:
GOOS: linux
CGO_ENABLED: "0"
run: |
make build-static-ci
- name: publish
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: target/vela-ansible
cache: true
tag_names: true
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
35 changes: 35 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# name of the action
name: publish

# trigger on push events with branch main
on:
push:
branches: [ main ]

# pipeline to execute
jobs:
publish:
runs-on: ubuntu-latest
container:
image: golang:1.17
steps:
- name: clone
uses: actions/checkout@v2
with:
# ensures we fetch tag history for the repository
fetch-depth: 0

- name: build
env:
GOOS: linux
CGO_ENABLED: '0'
run: |
make build-static-ci
- name: publish
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: target/vela-ansible
cache: true
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
41 changes: 41 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# name of the action
name: reviewdog

# trigger on pull_request events
on:
pull_request:

# pipeline to execute
jobs:
diff-review:
runs-on: ubuntu-latest
container:
image: golang:1.17
steps:
- name: clone
uses: actions/checkout@v2

- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--config=.golangci.yml"
fail_on_error: true
filter_mode: diff_context
reporter: github-pr-review

full-review:
runs-on: ubuntu-latest
container:
image: golang:1.17
steps:
- name: clone
uses: actions/checkout@v2

- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
github_token: ${{ secrets.github_token }}
golangci_lint_flags: "--config=.golangci.yml"
fail_on_error: false
filter_mode: nofilter
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# name of the action
name: test

# trigger on pull_request or push events
on:
pull_request:
push:

# pipeline to execute
jobs:
test:
runs-on: ubuntu-latest
container:
image: golang:1.17
steps:
- name: clone
uses: actions/checkout@v2

- name: test
run: |
go test -race -covermode=atomic -coverprofile=coverage.out ./...
- name: coverage
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.out
28 changes: 28 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# name of the action
name: validate

# trigger on pull_request or push events
on:
pull_request:
push:

# pipeline to execute
jobs:
validate:
runs-on: ubuntu-latest
container:
image: golang:1.17
steps:
- name: clone
uses: actions/checkout@v2

- name: validate
run: |
# Check that go mod tidy produces a zero diff; clean up any changes afterwards.
go mod tidy && git diff --exit-code; code=$?; git checkout -- .; (exit $code)
# Check that go vet ./... produces a zero diff; clean up any changes afterwards.
go vet ./... && git diff --exit-code; code=$?; git checkout -- .; (exit $code)
# Check that go fmt ./... produces a zero diff; clean up any changes afterwards.
go fmt ./... && git diff --exit-code; code=$?; git checkout -- .; (exit $code)
# Check that go fix ./... produces a zero diff; clean up any changes afterwards.
go fix ./... && git diff --exit-code; code=$?; git checkout -- .; (exit $code)
Loading

0 comments on commit f7c920f

Please sign in to comment.