Skip to content

Commit

Permalink
Merge pull request #1 from axone-protocol/chore/setup
Browse files Browse the repository at this point in the history
Chore/setup
  • Loading branch information
amimart authored Sep 27, 2024
2 parents 45f63de + a0efd4f commit 11969c6
Show file tree
Hide file tree
Showing 23 changed files with 934 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
.github/
35 changes: 31 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
- package-ecosystem: github-actions
directory: /
schedule:
interval: "daily"
interval: daily
open-pull-requests-limit: 2
reviewers:
- "axone-protocol/maintainers"
- amimart
- ccamel
assignees:
- amimart
- ccamel
- package-ecosystem: gomod
directory: /
schedule:
interval: daily
open-pull-requests-limit: 5
reviewers:
- amimart
- ccamel
assignees:
- amimart
- ccamel
- package-ecosystem: docker
directory: /
schedule:
interval: daily
open-pull-requests-limit: 2
reviewers:
- amimart
- ccamel
assignees:
- amimart
- ccamel
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build

on:
workflow_call:

push:
branches: [main]

pull_request:
branches: [main]

concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

jobs:
build-go:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Setup Go environment
uses: actions/[email protected]
with:
go-version: '1.22'

- name: Build go project
run: |
make build
106 changes: 106 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,112 @@ jobs:
- name: Lint yaml files
uses: ibiqlik/[email protected]

lint-go:
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Find changed go files
id: changed-go-files
uses: tj-actions/[email protected]
with:
files: |
**/*.go
go.mod
go.sum
- name: Setup Go environment
uses: actions/[email protected]
if: steps.changed-go-files.outputs.any_changed == 'true'
with:
go-version: "1.22"
cache: false

- name: Lint go code (golangci-lint)
uses: golangci/golangci-lint-action@v6
if: steps.changed-go-files.outputs.any_changed == 'true'
with:
version: v1.59

- name: Lint go code (gofumpt)
if: steps.changed-go-files.outputs.any_changed == 'true'
run: |
go install mvdan.cc/[email protected]
if [ "$(gofumpt -l .)" != "" ]; then
echo "❌ Code is not gofumpt!"
exit 1
fi
echo "✅ Code is gofumpt!"
analyze-go:
runs-on: ubuntu-22.04
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Find changed go files
id: changed-go-files
uses: tj-actions/[email protected]
with:
files: |
**/*.go
go.mod
go.sum
- name: Setup Go environment
uses: actions/[email protected]
with:
go-version: "1.22"
cache: false

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: "go"

- name: Autobuild project
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3

lint-dockerfile:
runs-on: ubuntu-22.04
if: github.actor != 'dependabot[bot]'
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Lint dockerfile (hadolint)
uses: hadolint/[email protected]
with:
verbose: true

lint-shell:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Lint shell scripts
uses: ludeeus/[email protected]
with:
scandir: .
version: "v0.9.0"
env:
SHELLCHECK_OPTS: -e SC2034

lint-branch-name:
runs-on: ubuntu-22.04
if: github.actor != 'dependabot[bot]' && github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened')
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish

on:
push:
branches: [ main ]
tags: [ "v*" ]

concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: true

jobs:
publish-docker-images:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Extract metadata (tags, labels) for Docker
id: docker_metadata
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }},value=nightly
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
labels: |
org.opencontainers.image.vendor=OKP4
- name: Login to Docker registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.DOCKER_REGISTRY_ID }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}

- name: Build and publish image(s)
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker_metadata.outputs.tags }}
labels: ${{ steps.docker_metadata.outputs.labels }}
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Release

on:
workflow_dispatch:

jobs:
lint:
if: github.ref == 'refs/heads/main' && github.actor == 'bot-anik'
uses: ./.github/workflows/lint.yml

build:
if: github.ref == 'refs/heads/main' && github.actor == 'bot-anik'
uses: ./.github/workflows/build.yml

test:
if: github.ref == 'refs/heads/main' && github.actor == 'bot-anik'
uses: ./.github/workflows/test.yml

perfom-release:
if: github.ref == 'refs/heads/main' && github.actor == 'bot-anik'
needs:
- lint
- build
- test
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
token: ${{ secrets.OPS_TOKEN }}

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.BOT_GPG_PASSPHRASE }}
git_config_global: true
git_user_signingkey: true
git_commit_gpgsign: true

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Release project
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: 22.0.5
branch: main
extra_plugins: |
@semantic-release/changelog
@semantic-release/exec
@semantic-release/git
[email protected]
extends: |
[email protected]
env:
GITHUB_TOKEN: ${{ secrets.OPS_TOKEN }}
GIT_AUTHOR_NAME: ${{ vars.BOT_GIT_AUTHOR_NAME }}
GIT_AUTHOR_EMAIL: ${{ vars.BOT_GIT_AUTHOR_EMAIL }}
GIT_COMMITTER_NAME: ${{ vars.BOT_GIT_COMMITTER_NAME }}
GIT_COMMITTER_EMAIL: ${{ vars.BOT_GIT_COMMITTER_EMAIL }}
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test

on:
workflow_call:

push:
branches: [main]

pull_request:
branches: [main]

concurrency:
group: test-${{ github.ref }}
cancel-in-progress: true

jobs:
test-go:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Setup Go environment
uses: actions/[email protected]
with:
go-version: "1.22"

- name: Test go project
run: |
make test-go
32 changes: 32 additions & 0 deletions .github/workflows/thank.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Give thanks

on:
workflow_dispatch:

push:
branches: [ main ]

jobs:
give-thanks:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Find changed dependencies
id: changed-dependencies
uses: tj-actions/[email protected]
with:
files: |
go.mod
- name: Give thanks!
if: steps.changed-dependencies.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch'
run: |
docker run --rm \
-v $(pwd):/home \
psampaz/gothanks:v0.4.0 \
-y \
-github-token=${{ secrets.OPS_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
target/
.idea/
.vscode/
.DS_Store
Loading

0 comments on commit 11969c6

Please sign in to comment.