Skip to content
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
118 changes: 118 additions & 0 deletions .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Copyright 2022 Dhi Aurrahman
# Licensed under the Apache License, Version 2.0 (the "License")

name: "commit"

on:
push:
branches:
- main
paths-ignore:
- "**/*.md"
- "**/*.png"
pull_request:
branches:
- main
paths-ignore:
- "**/*.md"
- "**/*.png"

# Allows triggering the workflow manually in github actions page.
workflow_dispatch:

defaults:
run: # use bash for all operating systems unless overridden
shell: bash

jobs:
check:
name: check
runs-on: ubuntu-20.04
timeout-minutes: 90 # instead of 360 by default.
strategy:
fail-fast: false # don't fail fast as sometimes failures are operating system specific
steps:
- name: Cancel when duplicated
uses: styfle/cancel-workflow-action@0.4.1
with:
access_token: ${{ github.token }}

- name: Checkout
uses: actions/checkout@v2 # shallow checkout.

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: "1.17.x"

- name: Download cache for Tools
uses: actions/cache@v2
with:
path: ./.cache/tools
# Downloading cached tools needs to use an exact key, since we
# currently don't do versioning for each cached binary.
key: ${{ runner.os }}-check-tools-${{ hashFiles('Tools.mk') }}

- name: Download cache for Go
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
# When we update Tools.mk, there is a possibility we download a new Go dependencies.
key: ${{ runner.os }}-check-go-${{ hashFiles('go.mod', 'go.sum', 'Tools.mk') }}
restore-keys: ${{ runner.os }}-check-go

- name: Get Linter cache key
run: |
echo "::set-output name=name::$(/bin/date -u "+%Y%m%d")"
id: get-linter-cache-key
# We cache golangci-lint run per day.
- name: Download cache for Linter
uses: actions/cache@v2
with:
path: ./.cache/golangci-lint
key: eag-commit-${{ runner.os }}-golangci-lint-${{ hashFiles('go.mod') }}-${{ steps.get-linter-cache-key.outputs.name }}
restore-keys: eag-commit-${{ runner.os }}-golangci-lint-

- name: Check
run: make check # `make check` does all the necessary checks.

test:
needs: check
name: test
runs-on: ubuntu-20.04
timeout-minutes: 90 # instead of 360 by default.
strategy:
fail-fast: false # don't fail fast as sometimes failures are operating system specific

steps:
- name: Cancel when duplicated
uses: styfle/cancel-workflow-action@0.4.1
with:
access_token: ${{ github.token }}

- name: Checkout
uses: actions/checkout@v2 # shallow checkout.

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: "1.17.x"

- name: Download cache for Tools
uses: actions/cache@v2
with:
path: ./.cache/tools
# Downloading cached tools needs to use an exact key, since we
# currently don't do versioning for each cached binary.
key: ${{ runner.os }}-check-tools-${{ hashFiles('Tools.mk') }}

- name: Download cache for Go
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
# When we update Tools.mk, there is a possibility we download a new Go dependencies.
key: ${{ runner.os }}-go-${{ hashFiles('go.mod', 'go.sum', 'Tools.mk') }}
restore-keys: ${{ runner.os }}-go

- name: Test and build
run: make test build
81 changes: 81 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright 2022 Dhi Aurrahman
# Licensed under the Apache License, Version 2.0 (the "License")

name: "release"

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+**" # For example: v0.5.0 v0.5.1-rc2

defaults:
run: # use bash for all operating systems unless overridden.
shell: bash
jobs:
dist:
name: dist
runs-on: ubuntu-20.04
timeout-minutes: 90 # instead of 360 by default.
strategy:
fail-fast: false # don't fail fast as sometimes failures are operating system specific.

steps:
- name: Cancel when duplicated
uses: styfle/cancel-workflow-action@0.4.1
with:
access_token: ${{ github.token }}

- name: Checkout
uses: actions/checkout@v2 # shallow checkout.

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: "1.17.x"

- name: Download cache for Tools
# if: matrix.mode == 'website' # this is required only for website.
uses: actions/cache@v2
with:
path: ./.cache/tools
# Downloading cached tools needs to use an exact key, since we
# currently don't do versioning for each cached binary.
key: ${{ runner.os }}-tools-${{ hashFiles('Tools.mk') }}

- name: Download cache for Go
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
# When we update Tools.mk, there is a possibility we download a new Go dependencies.
key: ${{ runner.os }}-go-${{ hashFiles('go.mod', 'go.sum', 'Tools.mk') }}
restore-keys: ${{ runner.os }}-go

- name: Create artifacts # We strip the "v"-prefix from the current tag.
run: VERSION=${GITHUB_REF#refs/tags/v} MODE=${{ matrix.mode }} make dist

- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: dist
path: dist

release:
name: release
runs-on: ubuntu-20.04
needs: dist
timeout-minutes: 90 # instead of 360 by default.
steps:
- name: Cancel when duplicated
uses: styfle/cancel-workflow-action@0.4.1
with:
access_token: ${{ github.token }}

- name: Download artifacts # get all of the uploaded artifacts
uses: actions/download-artifact@v2

- name: Release downloaded artifacts
uses: softprops/action-gh-release@v1
with:
files: |
dist/**/*.tar.gz
dist/**/*.zip
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ build: $(current_binary) ## Build the proxy binary
# TODO(dio): Generate checksums for the assets.
dist: $(archives) ## Generate release assets

# By default, unless GOMAXPROCS is set via an environment variable or explicity in the code, the
# tests are run with GOMAXPROCS=1. This is problematic if the a test requires more than one CPU, for
# example when running t.Parallel() in a test.
export GOMAXPROCS ?=4
test: ## Run all unit tests
@printf "$(ansi_format_dark)" $@ "running unit tests"
@$(go) test $(testable_go_packages)
@printf "$(ansi_format_bright)" $@ "ok"

check: ## Verify contents of last commit
$(MAKE) format
$(MAKE) lint
@if [ ! -z "`git status -s`" ]; then \
echo "The following differences will fail CI until committed:"; \
git diff --exit-code; \
fi

format: go.mod $(all_nongen_go_sources) $(goimports) ## Format all Go sources
@printf "$(ansi_format_dark)" $@ "formatting files"
@$(go) mod tidy
Expand Down
3 changes: 2 additions & 1 deletion runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (r *Runner) Run(ctx context.Context, args []string) error {

<-ctx.Done()

starter.Kill()
_ = starter.Kill()

return starter.Wait()
}
14 changes: 14 additions & 0 deletions runner/starter_darwin.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2022 Dhi Aurrahman
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package runner

import (
Expand Down
14 changes: 14 additions & 0 deletions runner/starter_linux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2022 Dhi Aurrahman
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package runner

import (
Expand Down
14 changes: 14 additions & 0 deletions runner/starter_windows.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2022 Dhi Aurrahman
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package runner

import (
Expand Down