Skip to content

Commit

Permalink
integration-pass-1
Browse files Browse the repository at this point in the history
  • Loading branch information
sheurich committed Feb 27, 2024
1 parent c98f5d0 commit de10df3
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 121 deletions.
61 changes: 19 additions & 42 deletions .github/workflows/ci.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
name: CI
# Workflow is triggered on:
# - every pull request to every branch
# - every push to every branch
# - every workflow_dispatch event
name: Build

# Run on push to main and any pull request.
on:
- pull_request
- push
- workflow_dispatch
# Workflow permissions:
# - write access to checks to allow actions to annotate code in the PR.
# - read access to the content for analysis.
# - write access to packages to allow the workflow to publish to the GitHub Container Registry.
# - read access to pull requests for `goveralls`.
push:
branches:
- main
pull_request:

permissions:
checks: write
contents: read
packages: write
pull-requests: read

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
app:
- pebble
- pebble-challtestsrv
go-arch:
- amd64
- arm64
Expand All @@ -35,16 +32,18 @@ jobs:
with:
check-latest: true
go-version-file: go.mod
- name: Build Go
- name: Build ${{ matrix.app }}
env:
APP: ${{ matrix.app }}
GOARCH: ${{ matrix.go-arch }}
GOOS: ${{ matrix.go-os }}
run: ./build.sh
run: ./build-release.sh
- name: Store artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.go-os }}-${{ matrix.go-arch }}
path: dist

docker:
needs:
- build
Expand All @@ -64,12 +63,11 @@ jobs:
- docker-arch: arm64
docker-os: windows
steps:
- name: Download all build artifacts
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: dist
pattern: dist-*
pattern: dist-${{ matrix.docker-os }}-${{ matrix.docker-arch }}
- name: Display artifacts
run: ls -lR dist
- name: Set up QEMU
Expand All @@ -82,7 +80,7 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
- name: Build and push ${{ github.repository }}/${{ matrix.app }} for ${{ matrix.docker-os }}/${{ matrix.docker-arch }}
uses: docker/build-push-action@v5
with:
build-args: APP=${{ matrix.app }}
Expand All @@ -93,24 +91,3 @@ jobs:
platforms: ${{ matrix.docker-os }}/${{ matrix.docker-arch }}
push: true
tags: ghcr.io/${{ github.repository }}/${{ matrix.app }}:${{ github.sha }}
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Check Go Modules
run: ./mods.sh
- name: GolangCI-Lint
uses: golangci/golangci-lint-action@v4
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run containerized test suite
run: ./t.sh
- name: Send code coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: profile.cov
49 changes: 16 additions & 33 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,36 @@
name: Checks

# Run on push to main and any pull request.
# Allow manual execution of the workflow.
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

permissions:
checks: write # Allow write access to checks to allow annotation of code in the PR.
contents: read
pull-requests: read

jobs:

checks:
name: Check Process
runs-on: ubuntu-latest
env:
GO_VERSION: oldstable
GOLANGCI_LINT_VERSION: v1.56.2
CGO_ENABLED: 0

steps:

- name: Check out code
uses: actions/checkout@v4
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Check and get dependencies
go-version: stable
- name: Check if go.mod is tidy
run: |
go mod tidy
git diff --exit-code go.mod
git diff --exit-code go.sum
- name: vendoring
run: go mod vendor

- name: vendoring diff
run: git diff --exit-code vendor/

# https://golangci-lint.run/usage/install#other-ci
- name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }}
git diff --exit-code go.mod go.sum || (echo "::error::go.mod and go.sum need to be tidy" && exit 1)
- name: Check if vendor directory is up to date
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION}
golangci-lint run
go mod vendor
git diff --exit-code vendor || (echo "::error::vendor directory needs to be updated" && exit 1)
- name: Run GolangCI-Lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
38 changes: 0 additions & 38 deletions .github/workflows/go-cross.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,3 @@ tags
.idea

.vscode/*

# Build output
/dist/
profile.cov
2 changes: 2 additions & 0 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# syntax=docker/dockerfile:1

ARG APP=${APP:-pebble}

# Set the base image dynamically based on the target OS
FROM --platform=${TARGETPLATFORM} \
alpine AS linux-base
Expand Down
11 changes: 7 additions & 4 deletions build.sh → build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@
# Fail on error, undefined, and uninitialized variables
set -eu

# Build the $APP command or all commands
app=${APP:-'...'}

# Set GOOS and GOARCH, default to current platform
arch=${GOARCH:-$(go env GOARCH)}
os=${GOOS:-$(go env GOOS)}

# Set our output directory
output=dist/${os}/${arch}

# Create the output directory
mkdir -p ${output}
mkdir -p "${output}"

# Settings for reproducible builds
export CGO_ENABLED=0
export GOWORK=off
ldflags="-s -w"

go build \
-ldflags="${ldflags}" \
-mod=vendor \
-o ${output}/ \
-o "${output}/" \
-trimpath \
-v \
./...
./cmd/"${app}"

0 comments on commit de10df3

Please sign in to comment.