Skip to content

Commit

Permalink
feat(baseline): init
Browse files Browse the repository at this point in the history
  • Loading branch information
Savid committed Feb 13, 2025
1 parent 5918d7f commit a2c0e7d
Show file tree
Hide file tree
Showing 25 changed files with 2,537 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @savid
61 changes: 61 additions & 0 deletions .github/workflows/alpha-releases.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: alpha releases

on:
push:
branches:
- 'release/*'

jobs:
tag-release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}
token: ${{ secrets.EPOBOT_TOKEN }}
- name: Get latest release version for this release branch
if: startsWith(github.ref, 'refs/heads/release/')
id: latest_version
run: |
# Extract suffix from branch name (e.g., 'dencun' from 'release/dencun')
RELEASE_SUFFIX=${GITHUB_REF#refs/heads/release/}
# Fetch all tags and get the latest that matches the pattern
# Using the refs/tags API
LATEST_VERSION=$(curl --silent "https://api.github.com/repos/$GITHUB_REPOSITORY/git/refs/tags" \
| jq -r --arg suffix "$RELEASE_SUFFIX" '.[] | select(.ref | test("refs/tags/v?[0-9]+\\.[0-9]+\\.[0-9]+-" + $suffix + "$")) | .ref' \
| sed 's|refs/tags/||' | sort -V | tail -n 1)
echo "Found latest $RELEASE_SUFFIX version: $LATEST_VERSION"
# Default to 0.0.0 if no matching release was found
if [[ -z "$LATEST_VERSION" ]]; then
LATEST_VERSION="0.0.0"
fi
# Increment the patch version using bash
LATEST_VERSION=$(echo "$LATEST_VERSION" | awk -F. -v OFS=. '{$NF = $NF + 1;} 1')
VERSION=$LATEST_VERSION-$RELEASE_SUFFIX
echo "Releasing version: $VERSION"
git config --global user.email "[email protected]"
git config --global user.name "ethpandaopsbot"
# Log the short commit SHA
SHORT_COMMIT=$(git rev-parse --short HEAD)
echo "Git commit: $SHORT_COMMIT"
git tag -a "$VERSION" -m "Release $VERSION"
echo "RELEASE_SUFFIX=$RELEASE_SUFFIX" >> $GITHUB_ENV
# Push the tag
git push origin "$VERSION"
env:
GITHUB_TOKEN: ${{ secrets.EPOBOT_TOKEN }}
45 changes: 45 additions & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: golangci-lint
on:
# push:
# tags:
# - v*
# branches:
# - master
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.23'
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.61

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
args: --timeout=5m

# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: true

# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
85 changes: 85 additions & 0 deletions .github/workflows/goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: goreleaser

on:
push:
tags:
- '*'

jobs:
goreleaser:
permissions:
contents: write
runs-on:
- self-hosted-ghr
- size-l-x64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Derive release suffix from tag (if it exists)
run: |
# Strip the 'refs/tags/' prefix
TAG_NAME=${GITHUB_REF#refs/tags/}
# Extract suffix from tag name after the last '-' (e.g., 'dencun' from 'v1.0.0-dencun')
RELEASE_SUFFIX=${TAG_NAME##*-}
# Check if the suffix is still a version pattern (e.g., 'v0.0.44'), in which case there's no suffix
if [[ $RELEASE_SUFFIX =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
RELEASE_SUFFIX=""
fi
echo "RELEASE_SUFFIX=$RELEASE_SUFFIX" >> $GITHUB_ENV
echo "Release suffix: $RELEASE_SUFFIX"
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Run apt-get update
run: sudo apt-get update
- name: Install cross-compiler for linux/arm64
run: sudo apt-get -y install gcc-aarch64-linux-gnu
- name: Install make
run: sudo apt-get -y install make
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Context for Buildx
shell: bash
id: buildx-context
run: |
docker context create builders
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
endpoint: builders
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Update GoReleaser config
run: |
cp .goreleaser.yaml .goreleaser.yaml.new
# If we have a RELEASE_SUFFIX, update the goreleaser config to not set
# the release as the latest
if [[ -n "$RELEASE_SUFFIX" ]]; then
echo "release:" >> .goreleaser.yaml.new
echo " prerelease: true" >> .goreleaser.yaml.new
echo " make_latest: false" >> .goreleaser.yaml.new
fi
- name: Run GoReleaser in Docker
run: |
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
-e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
-e DOCKER_USERNAME=${{ secrets.DOCKERHUB_USERNAME }} \
-e DOCKER_PASSWORD=${{ secrets.DOCKERHUB_TOKEN }} \
-v /var/run/docker.sock:/var/run/docker.sock \
-e RELEASE_SUFFIX=${{ env.RELEASE_SUFFIX }} \
goreleaser/goreleaser-cross:v1.22.2 release --clean --config .goreleaser.yaml.new
45 changes: 45 additions & 0 deletions .github/workflows/test-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: test-build

on:
pull_request:
workflow_dispatch:

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Run apt-get update
run: sudo apt-get update
- name: Install cross-compiler for linux/arm64
run: sudo apt-get -y install gcc-aarch64-linux-gnu
- name: Install make
run: sudo apt-get -y install make
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Context for Buildx
shell: bash
id: buildx-context
run: |
docker context create builders
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
endpoint: builders
- name: Run GoReleaser in Docker
run: |
docker run --rm \
-v ${{ github.workspace }}:/workspace \
-w /workspace \
-e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
-v /var/run/docker.sock:/var/run/docker.sock \
-e RELEASE_SUFFIX="test" \
goreleaser/goreleaser-cross:v1.22.2 release --clean --config .goreleaser.yaml --skip=publish --skip=validate
34 changes: 34 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Go Test

on:
pull_request:

workflow_dispatch:
branches: [ '**' ]

jobs:
full_ci:
strategy:
matrix:
go_version: [ 1.23.x ]

runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go_version }}

- name: run tests
run: go test -json ./... > test.json

- name: Annotate tests
if: always()
uses: guyarb/[email protected]
with:
test-results: test.json

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
config.yaml
__debug_bin*
.vscode/launch.json
.goreleaser.yaml.new
.aider*
validator-tools
67 changes: 67 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
linters-settings:
errcheck:
check-type-assertions: true
goconst:
min-len: 2
min-occurrences: 3
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
govet:
enable:
- shadow
nolintlint:
require-explanation: true
require-specific: true

linters:
disable-all: true
enable:
- asasalint
- bidichk
- bodyclose
- containedctx
- decorder
- dogsled
- durationcheck
- errcheck
- errname
- copyloopvar
- goconst
- gocritic
- gocyclo
- gofmt
- goheader
- goimports
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- nilerr
- nilerr
- nilnil
- nlreturn
- nolintlint
- nosprintfhostport
- prealloc
- predeclared
- promlinter
- reassign
- staticcheck
- stylecheck
- thelper
- tparallel
- typecheck
- unconvert
- unused
- whitespace
- wsl

run:
issues-exit-code: 1
Loading

0 comments on commit a2c0e7d

Please sign in to comment.