Skip to content

Commit

Permalink
ci: add basic CI functionalities
Browse files Browse the repository at this point in the history
Signed-off-by: leongross <leon.gross@9elements.com>
  • Loading branch information
leongross committed Feb 13, 2025
1 parent 3a054c6 commit ae1a5c6
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Go
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
linters:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
- name: Check vendored dependencies
run: |
go mod tidy
go mod verify
- name: gofmt
run: test -z "$(gofmt -s -l $(find -name '*.go' | grep -v /vendor/))"

build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'

- name: Build Example
run: go run -mod=mod -v examples/example.go

- name: Vet Test
run: go vet -composites=false -mod=mod ./...

multi-os-arch:
strategy:
matrix:
arch: [amd64, arm, arm64]

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.22.x"

- name: Build
run: |
GOOS=linux GOARCH=${{ matrix.arch }} go run examples/examples.go
28 changes: 28 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: golangci-lint
on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read
pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.63.4
args: --out-format=line-number --timeout=5m
35 changes: 35 additions & 0 deletions examples/example.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main

import (
"github.com/u-root/cpuid"
"fmt"
)

func main() {
fmt.Printf("VendorString: %s\n", cpuid.VendorIdentificatorString)

fmt.Printf("Features: ")
for i := uint64(0); i < 64; i++ {
if cpuid.HasFeature(1 << i) {
fmt.Printf("%s ", cpuid.FeatureNames[1<<i])
}
}
fmt.Printf("\n")

fmt.Printf("ExtendedFeatures: ")
for i := uint64(0); i < 64; i++ {
if cpuid.HasExtendedFeature(1 << i) {
fmt.Printf("%s ", cpuid.ExtendedFeatureNames[1<<i])
}
}
fmt.Printf("\n")

fmt.Printf("ExtraFeatures: ")
for i := uint64(0); i < 64; i++ {
if cpuid.HasExtraFeature(1 << i) {
fmt.Printf("%s ", cpuid.ExtraFeatureNames[1<<i])
}
}
fmt.Printf("\n")
}

0 comments on commit ae1a5c6

Please sign in to comment.