8000 feat: Add golangci-lint & github action CI (#80) by Jeongseup · Pull Request #86 · cosmostation/cvms · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

feat: Add golangci-lint & github action CI (#80) #86

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

Merged
merged 2 commits into from
May 23, 2025
Merged
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
122 changes: 122 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: CVMS CI

# When this workflow is triggered
on:
push: # On every push to any branch
branches:
- develop # Or your fork's default branch name, e.g., develop, master
- release
tags:
- "v*.*.*" # For release tagging later
pull_request: # On every pull request targeting the main branch
branches:
- develop

jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest # Use the latest Ubuntu runner provided by GitHub

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.23" # Specify your Go version. Check your go.mod for this.
cache: true # Enable cac 10000 hing of Go modules to speed up subsequent runs

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.1.5
args: --timeout=5m

# TODO: Ignore this step for now
# Step 4: Run Go Tests
# - name: Run Go Tests
# run: go test -v ./...

- name: Build Go Application (Verification)
run: go build -v ./... # 코드 컴파일 가능성 검증

build-and-push-docker-image:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs: build-and-test # Ensures this job runs only if build-and-test succeeds

# This job will only run for pushes (not PRs) to 'develop', 'release', or tags.
if: |
github.event_name == 'push' &&
(
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/release' ||
startsWith(github.ref, 'refs/tags/v')
)

steps:
- name: Checkout code
uses: actions/checkout@v4
# If you use git tags for versioning in Docker tags, fetch all history/tags
with:
fetch-depth: 0
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/cvms
tags: |
# For pushes to the 'develop' branch, tag the image as 'develop'.
# Enabled only when the push is to 'refs/heads/develop'.
type=raw,value=develop,enable=${{ github.ref == 'refs/heads/develop' }}

# For pushes to the 'release' branch, tag the image as 'release'.
# This can be used for release candidates or pre-releases.
# Enabled only when the push is to 'refs/heads/release'.
type=raw,value=release,enable=${{ github.ref == 'refs/heads/release' }}

# For Git tags (e.g., v1.2.3):
# Create a Docker tag that exactly matches the Git tag (e.g., v1.2.3).
type=semver,pattern={{version}}
# Create a Docker tag for the major and minor version (e.g., 1.2 from v1.2.3).
type=semver,pattern={{major}}.{{minor}}
# Create a Docker tag for the major version only (e.g., 1 from v1.2.3).
type=semver,pattern={{major}}

# Tag images built from any Git tag starting with 'v' also as 'latest'.
# Note: This means if you push e.g. v2.0.0-beta, it would also be tagged 'latest'.
# For a more sophisticated 'latest' tag pointing only to stable releases,
# consider using flavor options or more specific rules.
type=raw,value=latest,enable=${{startsWith(github.ref, 'refs/tags/v')}}

# For every push, create a Docker tag with the short commit SHA.
# This provides a unique, immutable tag for each build.
# Example: a1b2c3d
type=sha,prefix=,suffix=,format=short

- name: Set up QEMU (for multi-platform builds, optional)
uses: docker/setup-qemu-action@v3

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

- name: Login to GitHub Container Registry (GHCR)
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64 # Uncomment for multi-platform builds
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ custom_chains.yaml

# IDEA editor
.idea
**/.idea
**/.idea

# dev
lint-output.txt
Loading
0