Skip to content

Commit

Permalink
Merge branch 'air-verse:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
aroberts89 authored Aug 29, 2024
2 parents 8852781 + 6403f4d commit f2795b0
Show file tree
Hide file tree
Showing 33 changed files with 1,812 additions and 750 deletions.
52 changes: 29 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,62 @@
name: build
name: Build

on:
push:
pull_request:
branches: [master]

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
name: build
name: Build
runs-on: ${{ matrix.os }}
steps:
- name: check out code
uses: actions/checkout@v2
- name: setup Go 1.21
- name: Check out code
uses: actions/checkout@v4
- name: Setup Go
id: go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ^1.21
- name: build
go-version: ^1.22
- name: Install golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
- name: Install dependency
run: if [ $(uname) == "Darwin" ]; then brew install gnu-sed ;fi
- name: Build
run: make build
- name: install dependency
run: if [ $(uname) == "Darwin" ]; then brew install gnu-sed ;fi
- name: run Unit tests.
run: go install github.com/go-delve/delve/cmd/dlv@latest && go test ./... -v -covermode=count -coverprofile=coverage.txt
- name: upload Coverage report to CodeCov
uses: codecov/codecov-action@v2
- name: Run unit tests
run: go install github.com/go-delve/delve/cmd/dlv@latest && go test ./... -v -covermode=count -coverprofile=coverage.txt
- name: Upload Coverage report to CodeCov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
verbose: true

push_to_docker_latest:
name: push master code to docker latest image
name: Push master code to docker latest image
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: login to DockerHub
uses: docker/login-action@v1
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: build and push
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64
tags: cosmtrek/air:latest
- name: show image digest
- name: Show image digest
run: echo ${{ steps.docker_build.outputs.digest }}
48 changes: 25 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,54 @@
name: release
name: Release

on:
push:
pull_request:
branches: [ master ]
branches: [master]

jobs:
release:
name: release
name: Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: checkout code
uses: actions/checkout@v2
- name: setup Go
uses: actions/setup-go@v2
- name: Check out code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ^1.21
- name: set GOVERSION
go-version: ^1.22

- name: Set GOVERSION
run: echo "GOVERSION=$(go version | sed -r 's/go version go(.*)\ .*/\1/')" >> $GITHUB_ENV
- name: set AirVersion
- name: Set AirVersion
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: show version
- name: Show version
run: echo ${{ env.GOVERSION }} ${{ env.VERSION }}

- name: run GoReleaser
uses: goreleaser/goreleaser-action@v2
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --rm-dist
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: login to DockerHub
uses: docker/login-action@v1
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: push to docker hub
- name: Push to DockerHub
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64
tags: cosmtrek/air:${{ env.VERSION }}
- name: show docker image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Show docker image digest
run: echo ${{ steps.docker_build.outputs.digest }}
15 changes: 8 additions & 7 deletions .github/workflows/smoke_test.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
name: smoke_test
name: Smoke test

on:
push:
pull_request:

jobs:
smoke_test_ubuntu:
uses: cosmtrek/air/.github/workflows/smoke_test_reuse_job.yml@add_smoke_test
with:
uses: air-verse/air/.github/workflows/smoke_test_reuse_job.yml@master
with:
run_on: ubuntu-latest
smoke_test_macos:
uses: cosmtrek/air/.github/workflows/smoke_test_reuse_job.yml@add_smoke_test
with:
uses: air-verse/air/.github/workflows/smoke_test_reuse_job.yml@master
with:
run_on: macos-latest
smoke_test_windows:
uses: cosmtrek/air/.github/workflows/smoke_test_window_reust_job.yml@fix_window_arg_bug
with:
uses: air-verse/air/.github/workflows/smoke_test_reuse_job_windows.yml@master
with:
run_on: windows-latest
26 changes: 13 additions & 13 deletions .github/workflows/smoke_test_reuse_job.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Reusable smoke_test
name: Reusable smoke test

on:
workflow_call:
Expand All @@ -9,29 +9,29 @@ on:

jobs:
smoke_test:
name: smoke_test
name: Smoke test
runs-on: ${{ inputs.run_on }}
steps:
- name: check out code
uses: actions/checkout@v2
- name: setup Go 1.21
- name: Check out code
uses: actions/checkout@v4
- name: Setup Go
id: go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ^1.21
- name: install
go-version: ^1.22
- name: Install
run: make install
- name: check rebuild
- name: Check rebuild
id: check_rebuild
working-directory: ./smoke_test/check_rebuild
run: |
run: |
nohup air > nohup.out 2> nohup.err < /dev/null &
sleep 15
echo "" >> main.go
sleep 5
cat nohup.out
cat nohup.out
grep "running" nohup.out | wc -l | if [ "$(cat -)" -eq "2" ]; then echo "::set-output name=value::PASS"; else echo "::set-output name=value::FAIL"; fi
- uses: nick-invision/assert-action@v1
- uses: nick-invision/assert-action@v2
with:
expected: "PASS"
actual: ${{ steps.check_rebuild.outputs.value }}
actual: ${{ steps.check_rebuild.outputs.value }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Reusable smoke_test
name: Reusable smoke test on Windows

on:
workflow_call:
Expand All @@ -9,31 +9,31 @@ on:

jobs:
smoke_test:
name: smoke_test
name: Smoke test
runs-on: ${{ inputs.run_on }}
steps:
- name: check out code
uses: actions/checkout@v2
- name: setup Go 1.21
- name: Check out code
uses: actions/checkout@v4
- name: Setup Go
id: go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ^1.21
go-version: ^1.22
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install depend
run: |
python -m pip install pexpect
- name: install
- name: Install
run: make install
- name: check rebuild
- name: Check rebuild
id: check_rebuild
working-directory: ./smoke_test
run: |
python smoke_test.py
- uses: nick-invision/assert-action@v1
run: |
python smoke_test.py
- uses: nick-invision/assert-action@v2
with:
expected: "PASS"
actual: ${{ steps.check_rebuild.outputs.value }}
16 changes: 16 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
run:
timeout: 2m

linters:
disable-all: true
enable:
- errcheck # Errcheck is a program for checking for unchecked errors in go programs.
- gci # Gci controls Go package import order and makes it always deterministic
- goimports # checks that goimports was run
- ineffassign # Detects when assignments to existing variables are not used
- misspell # spell checker
- revive # configurable linter for Go. Drop-in replacement of golint
- staticcheck # go vet on steroids
- stylecheck # static analysis, finds bugs and performance issues, offers simplifications, and enforces style rules
- unconvert # Remove unnecessary type conversions
- unused # Checks Go code for unused constants, variables, functions and types
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.21 AS builder
FROM golang:1.22 AS builder

MAINTAINER Rick Yu <[email protected]>
LABEL maintainer="Rick Yu <[email protected]>"

ENV GOPATH /go
ENV GO111MODULE on
Expand All @@ -12,7 +12,7 @@ RUN --mount=type=cache,target=/go/pkg/mod go mod download

RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build make ci && make install

FROM golang:1.21
FROM golang:1.22

COPY --from=builder /go/bin/air /go/bin/air

Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ LDFLAGS += -X "main.airVersion=$(AIRVER)"
LDFLAGS += -X "main.goVersion=$(shell go version | sed -r 's/go version go(.*)\ .*/\1/')"

GO := GO111MODULE=on CGO_ENABLED=0 go
GOLANGCI_LINT_VERSION = v1.56.2

.PHONY: init
init:
go install golang.org/x/lint/golint@latest
init: install-golangci-lint
go install golang.org/x/tools/cmd/goimports@latest
@echo "Install pre-commit hook"
@ln -s $(shell pwd)/hooks/pre-commit $(shell pwd)/.git/hooks/pre-commit || true
@chmod +x ./hack/check.sh

.PHONY: install-golangci-lint
install-golangci-lint:
ifeq (, $(shell which golangci-lintx))
@$(shell curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT_VERSION))
endif

.PHONY: setup
setup: init
git init
Expand Down
Loading

0 comments on commit f2795b0

Please sign in to comment.