Skip to content

Commit

Permalink
Merge pull request #101 from mmlb/better-formatting-and-linting
Browse files Browse the repository at this point in the history
## Description

Replace golangci-lint-action with golangci-lint from nixpkgs.

## Why is this needed

Ultimate fix for the golangci-lint-action errors messing with CI. Continuation of #100
  • Loading branch information
mmlb authored Nov 9, 2020
2 parents eaa3935 + e4e7621 commit e400da1
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 64 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci-non-go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash ../../shell.nix
#shellcheck shell=bash

set -eux

failed=0

if ! git ls-files '*.md' '*.yaml' '*.yml' | xargs prettier --list-different --write; then
failed=1
fi

if ! shfmt -f . | xargs shfmt -l -d; then
failed=1
fi

if ! shfmt -f . | xargs shellcheck; then
failed=1
fi

if ! git diff | (! grep .); then
failed=1
fi

exit "$failed"
109 changes: 56 additions & 53 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,63 @@ jobs:
env:
CGO_ENABLED: 0
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
lfs: true
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: '1.14.6'
- name: goimports
run: go get golang.org/x/tools/cmd/goimports && goimports -d . | (! grep .)
- name: go vet
run: go vet ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.30
args: -v -D errcheck
- name: go test
run: go test -v ./...
- name: go test coverage
run: go test -coverprofile=coverage.txt ./...
- name: upload codecov
run: bash <(curl -s https://codecov.io/bash)
- name: Checkout code
uses: actions/checkout@v2
with:
lfs: true
- name: Install nix
uses: cachix/install-nix-action@v12
with:
nix_path: nixpkgs=channel:nixpkgs-unstable
- name: Non Go formatters and linters
run: ./.github/workflows/ci-non-go.sh
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "1.14.6"
- name: goimports
run: go get golang.org/x/tools/cmd/goimports && goimports -d . | (! grep .)
- name: go vet
run: go vet ./...
- name: golangci-lint brought to you by Nix
run: nix-shell --run 'GOROOT= golangci-lint run -v -D errcheck'
- name: go test
run: go test -v ./...
- name: go test coverage
run: go test -coverprofile=coverage.txt ./...
- name: upload codecov
run: bash <(curl -s https://codecov.io/bash)
docker-images:
runs-on: ubuntu-latest
needs: [validation]
steps:
- name: Docker Image Tag for Sha
id: docker-image-tag
run: |
echo ::set-output name=tags::quay.io/tinkerbell/boots:latest,quay.io/tinkerbell/boots:sha-${GITHUB_SHA::8}
- name: Checkout code
uses: actions/checkout@v2
with:
lfs: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
version: "v0.4.1"
- name: Login to quay.io
uses: docker/login-action@v1
if: ${{ startsWith(github.ref, 'refs/heads/master') }}
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: quay.io/tinkerbell/boots
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
cache-from: type=registry,ref=quay.io/tinkerbell/boots:latest
push: ${{ startsWith(github.ref, 'refs/heads/master') }}
tags: ${{ steps.docker-image-tag.outputs.tags }}
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
- name: Docker Image Tag for Sha
id: docker-image-tag
run: |
echo ::set-output name=tags::quay.io/tinkerbell/boots:latest,quay.io/tinkerbell/boots:sha-${GITHUB_SHA::8}
- name: Checkout code
uses: actions/checkout@v2
with:
lfs: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
version: "v0.4.1"
- name: Login to quay.io
uses: docker/login-action@v1
if: ${{ startsWith(github.ref, 'refs/heads/master') }}
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: quay.io/tinkerbell/boots
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
cache-from: type=registry,ref=quay.io/tinkerbell/boots:latest
push: ${{ startsWith(github.ref, 'refs/heads/master') }}
tags: ${{ steps.docker-image-tag.outputs.tags }}
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Boots

[![Build Status](https://cloud.drone.io/api/badges/tinkerbell/boots/status.svg)](https://cloud.drone.io/tinkerbell/boots)
![](https://img.shields.io/badge/Stability-Experimental-red.svg)

Expand All @@ -22,6 +23,7 @@ git lfs pull
```

Running the Tests

```
# make the files
make all
Expand All @@ -30,6 +32,7 @@ go test
```

Build/Run Boots

```
# run boots
./boots
Expand All @@ -40,4 +43,3 @@ You can use NixOS shell, which will have the Git-LFS, Go and others
`nix-shell`

Note: for mac users, you will need to comment out the line `pkgsCross.aarch64-multiplatform.buildPackages.gcc` in order for the build to work

20 changes: 10 additions & 10 deletions ipxe/ipxe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ set -e
# Deps on ubuntu
# apt-get -y --no-install-recommends install build-essential gcc-aarch64-linux-gnu git liblzma-dev

name=$(basename $1)
name=$(basename "$1")
topdir=${1%%/*}
version=$2
short_version="$(echo $version | cut -c1-5)"
sed -i '/#define OCSP_CHECK/ d' $topdir/src/config/crypto.h
short_version="$(echo "$version" | cut -c1-5)"
sed -i '/#define OCSP_CHECK/ d' "$topdir/src/config/crypto.h"
case $name in
undionly.kpxe)
cp $topdir/src/config/local/general.undionly.h $topdir/src/config/local/general.h
make -C $topdir/src VERSION_PATCH=255 EXTRAVERSION="+ ($short_version)" bin/undionly.kpxe
cp "$topdir/src/config/local/general.undionly.h" "$topdir/src/config/local/general.h"
make -C "$topdir/src" VERSION_PATCH=255 EXTRAVERSION="+ ($short_version)" bin/undionly.kpxe
;;
ipxe.efi)
cp $topdir/src/config/local/general.efi.h $topdir/src/config/local/general.h
make -C $topdir/src VERSION_PATCH=255 EXTRAVERSION="+ ($short_version)" bin-x86_64-efi/ipxe.efi
cp "$topdir/src/config/local/general.efi.h" "$topdir/src/config/local/general.h"
make -C "$topdir/src" VERSION_PATCH=255 EXTRAVERSION="+ ($short_version)" bin-x86_64-efi/ipxe.efi
;;
snp.efi)
cp $topdir/src/config/local/general.aarch64-snp-nolacp.h $topdir/src/config/local/general.h
cp "$topdir/src/config/local/general.aarch64-snp-nolacp.h" "$topdir/src/config/local/general.h"
# http://lists.ipxe.org/pipermail/ipxe-devel/2018-August/006254.html
sed -i '/^WORKAROUND_CFLAGS/ s|^|#|' $topdir/src/arch/arm64/Makefile
CROSS_COMPILE=aarch64-unknown-linux-gnu- make -C $topdir/src VERSION_PATCH=255 EXTRAVERSION="+ ($short_version)" bin-arm64-efi/snp.efi
sed -i '/^WORKAROUND_CFLAGS/ s|^|#|' "$topdir/src/arch/arm64/Makefile"
CROSS_COMPILE=aarch64-unknown-linux-gnu- make -C "$topdir/src" VERSION_PATCH=255 EXTRAVERSION="+ ($short_version)" bin-arm64-efi/snp.efi
;;
*) echo "unknown target: $1" && exit 1 ;;
esac
4 changes: 4 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ mkShell {
git-lfs
gnumake
go
golangci-lint
go-bindata
mockgen
nodePackages.prettier
pkgsCross.aarch64-multiplatform.buildPackages.gcc
protobuf
shfmt
shellcheck
xz
];
}

0 comments on commit e400da1

Please sign in to comment.