-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1 from smlx/actions-draft
Add github actions
- Loading branch information
Showing
14 changed files
with
373 additions
and
10 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,15 @@ | ||
const Configuration = { | ||
/* | ||
* Resolve and load @commitlint/config-conventional from node_modules. | ||
* Referenced packages must be installed | ||
*/ | ||
extends: ['@commitlint/config-conventional'], | ||
/* | ||
* Any rules defined here will override rules from @commitlint/config-conventional | ||
*/ | ||
rules: { | ||
'body-max-line-length': [1, 'always', 80], | ||
}, | ||
}; | ||
|
||
module.exports = Configuration; |
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 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: docker | ||
directory: / | ||
schedule: | ||
interval: daily | ||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: daily | ||
- package-ecosystem: gomod | ||
directory: / | ||
schedule: | ||
interval: daily |
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 @@ | ||
# This list is the CNCF list, without the Golang license and with the MPL. | ||
# https://github.com/cncf/foundation/blob/main/allowed-third-party-license-policy.md | ||
allow-licenses: | ||
- 'Apache-2.0' | ||
- 'BSD-2-Clause' | ||
- 'BSD-2-Clause-FreeBSD' | ||
- 'BSD-3-Clause' | ||
- 'ISC' | ||
- 'MIT' | ||
- 'MPL-2.0' | ||
- 'PostgreSQL' | ||
- 'Python-2.0' | ||
- 'X11' | ||
- 'Zlib' |
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,70 @@ | ||
name: Build | ||
on: pull_request | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: stable | ||
- name: Set up environment | ||
run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
version: latest | ||
args: build --snapshot --clean | ||
- name: Tar up binaries | ||
# work around limitations in the upload/download artifact actions | ||
# https://github.com/actions/download-artifact#limitations | ||
run: tar -cvf dist.tar dist | ||
- name: Upload binaries tar file | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: dist.tar | ||
path: dist.tar | ||
buildimage: | ||
if: ${{ !startsWith(github.head_ref, 'dependabot/') }} | ||
strategy: | ||
matrix: | ||
binary: | ||
- sems_mitm_exporter | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Download binaries tar file | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: dist.tar | ||
- name: Untar binaries | ||
run: tar -xvf dist.tar | ||
- name: Login to GHCR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Docker metadata | ||
# this id is namespaced per matrix run | ||
id: docker_metadata | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ghcr.io/${{ github.repository }}/${{ matrix.binary }} | ||
- name: Build and push ${{ matrix.binary }} container image | ||
id: docker_build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
push: true | ||
tags: ${{ steps.docker_metadata.outputs.tags }} | ||
labels: ${{ steps.docker_metadata.outputs.labels }} | ||
file: deploy/docker/Dockerfile | ||
context: dist/${{ matrix.binary }}_linux_amd64_v1 | ||
build-args: | ||
- BINARY=${{ matrix.binary }} |
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,32 @@ | ||
name: "CodeQL" | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: | ||
- go | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: ${{ matrix.language }} | ||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 |
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,30 @@ | ||
name: Coverage | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
coverage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Configure git | ||
run: | | ||
git config --global user.name "$GITHUB_ACTOR" | ||
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com" | ||
- name: Set up go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: stable | ||
- name: Calculate coverage | ||
run: | | ||
go test -v -covermode=count -coverprofile=coverage.out.raw -coverpkg=./... ./... | ||
grep -v mock_ coverage.out.raw > coverage.out | ||
- name: Convert coverage to lcov | ||
uses: jandelgado/gcov2lcov-action@v1 | ||
- name: Coveralls | ||
uses: coverallsapp/github-action@v2 | ||
with: | ||
github-token: ${{ secrets.github_token }} |
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 @@ | ||
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request | ||
name: Dependabot auto-merge | ||
on: pull_request | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
dependabot: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.actor == 'dependabot[bot]' }} | ||
steps: | ||
- name: Enable auto-merge for Dependabot PRs | ||
run: gh pr merge --auto --merge "$PR_URL" | ||
env: | ||
PR_URL: ${{github.event.pull_request.html_url}} | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
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,15 @@ | ||
name: 'Dependency Review' | ||
on: | ||
- pull_request | ||
permissions: | ||
contents: read | ||
jobs: | ||
dependency-review: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 'Checkout Repository' | ||
uses: actions/checkout@v4 | ||
- name: Dependency Review | ||
uses: actions/dependency-review-action@v3 | ||
with: | ||
config-file: '.github/dependency-review-config.yml' |
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,31 @@ | ||
name: Lint | ||
on: pull_request | ||
jobs: | ||
golangci-lint: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: stable | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
args: --timeout=180s | ||
commitlint: | ||
permissions: | ||
pull-requests: read | ||
contents: read | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Lint commit messages | ||
uses: wagoid/commitlint-github-action@v5 | ||
with: | ||
configFile: .github/commitlint.config.js |
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,110 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
tag: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
new-tag: ${{ steps.bump-tag.outputs.new }} | ||
new-tag-version: ${{ steps.bump-tag.outputs.new_tag_version }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Configure Git | ||
run: | | ||
git config --global user.name "$GITHUB_ACTOR" | ||
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com" | ||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: stable | ||
- name: Install ccv | ||
run: > | ||
curl -sSL https://github.com/smlx/ccv/releases/download/v0.3.2/ccv_0.3.2_linux_amd64.tar.gz | ||
| sudo tar -xz -C /usr/local/bin ccv | ||
- name: Bump tag if necessary | ||
id: bump-tag | ||
run: | | ||
if [ -z $(git tag -l $(ccv)) ]; then | ||
git tag $(ccv) | ||
git push --tags | ||
echo "new=true" >> $GITHUB_OUTPUT | ||
echo "new_tag_version=$(git tag --points-at HEAD)" >> $GITHUB_OUTPUT | ||
fi | ||
release: | ||
needs: tag | ||
if: needs.tag.outputs.new-tag == 'true' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: stable | ||
- name: Set up environment | ||
run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Tar up binaries | ||
run: tar -cvf dist.tar dist | ||
- name: Upload binaries tar file | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: dist.tar | ||
path: dist.tar | ||
releaseimage: | ||
strategy: | ||
matrix: | ||
binary: | ||
- sems_mitm_exporter | ||
needs: | ||
- tag | ||
- release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Download binaries tar file | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: dist.tar | ||
- name: Untar binaries | ||
run: tar -xvf dist.tar | ||
- name: Login to GHCR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Docker metadata | ||
# this id is namespaced per matrix run | ||
id: docker_metadata | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ghcr.io/${{ github.repository }}/${{ matrix.binary }} | ||
tags: | | ||
${{ needs.tag.outputs.new-tag-version }} | ||
latest | ||
- name: Build and push ${{ matrix.binary }} container image | ||
id: docker_build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
push: true | ||
tags: ${{ steps.docker_metadata.outputs.tags }} | ||
labels: ${{ steps.docker_metadata.outputs.labels }} | ||
file: deploy/docker/Dockerfile | ||
context: dist/${{ matrix.binary }}_linux_amd64_v1 | ||
build-args: | ||
- BINARY=${{ matrix.binary }} |
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,16 @@ | ||
name: Test | ||
on: pull_request | ||
jobs: | ||
go-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: stable | ||
- name: Run Tests | ||
run: go test -v ./... |
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,3 @@ | ||
FROM alpine:3.18 | ||
ENTRYPOINT ["/${BINARY}"] | ||
COPY ${BINARY} / |
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
Oops, something went wrong.