Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Switch to task from make #679

Merged
merged 5 commits into from
Apr 10, 2024
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
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ eval "$(devbox generate direnv --print-envrc)"

# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/
# for more details

export TASK_X_ANY_VARIABLES=1
15 changes: 8 additions & 7 deletions .github/workflows/checks-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ on:
branches:
- main

defaults:
run:
shell: bash

env:
TASK_X_ANY_VARIABLES: 1

jobs:
build-and-run:
runs-on: macos-13
defaults:
run:
shell: bash
steps:
- name: Check out code
uses: actions/checkout@v4
Expand All @@ -36,10 +40,7 @@ jobs:

- name: Build
run: |
devbox run -- \
make GORELEASER_FLAGS=$'--config=<(gojq --yaml-input --yaml-output \'del(.builds[0].goarch) | del(.builds[0].goos) | .builds[0].targets|=(["darwin_amd64_v1"])\' .goreleaser.yml) --skip=validate,publish' release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_PLATFORMS="\"darwin_amd64\"" devbox run -- task build:release-unpublished

- name: Run binary
run: |
Expand Down
91 changes: 68 additions & 23 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ on:
- opened
- synchronize
- reopened
branches:
- main

permissions:
contents: read

defaults:
run:
shell: bash

env:
TASK_X_ANY_VARIABLES: 1

jobs:
unit-test:
runs-on: ubuntu-22.04
defaults:
run:
shell: bash
permissions:
checks: write
pull-requests: write
Expand All @@ -33,8 +38,18 @@ jobs:
with:
enable-cache: true

- name: Go cache
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Run unit tests
run: devbox run -- make test
run: devbox run -- task test:unit

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
Expand All @@ -46,9 +61,6 @@ jobs:

e2e-test:
runs-on: ubuntu-22.04
defaults:
run:
shell: bash
permissions:
checks: write
pull-requests: write
Expand All @@ -69,7 +81,7 @@ jobs:
platforms: arm64

- name: Run e2e tests
run: devbox run -- make e2e-test
run: devbox run -- task test:e2e
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TMPDIR: ${{ runner.temp }}
Expand All @@ -84,9 +96,6 @@ jobs:

lint:
runs-on: ubuntu-22.04
defaults:
run:
shell: bash
steps:
- name: Check out code
uses: actions/checkout@v4
Expand All @@ -97,39 +106,75 @@ jobs:
enable-cache: true

- name: Export golang and golangci-lint versions
id: versions
run: |
echo "GOLANGCI_LINT_VERSION=v$(devbox run -- golangci-lint version --format short)" >>$GITHUB_ENV
echo "GO_VERSION=$(devbox run -- go version | grep -o "[[:digit:]]\+.[[:digit:]]\+\(.[[:digit:]]\+\)\?")" >>$GITHUB_ENV
echo "golangci-lint=$(devbox run -- golangci-lint version --format short)" >>"${GITHUB_OUTPUT}"
echo "golang=$(devbox run -- go version | grep -o "[[:digit:]]\+.[[:digit:]]\+\(.[[:digit:]]\+\)\?")" >>"${GITHUB_OUTPUT}"

- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
fail_on_error: true
reporter: github-pr-review
golangci_lint_version: ${{ env.GOLANGCI_LINT_VERSION }}
go_version: ${{ env.GO_VERSION }}
golangci_lint_version: v${{ steps.versions.outputs.golangci-lint }}
go_version: v${{ steps.versions.outputs.golang }}

lint-gha:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4

- name: actionlint
uses: reviewdog/action-actionlint@v1
with:
fail_on_error: true
reporter: github-pr-review

pre-commit:
runs-on: ubuntu-22.04
defaults:
run:
shell: bash
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Install devbox
uses: jetpack-io/[email protected]
with:
enable-cache: true

- name: Go cache
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Set up pre-commit cache
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
key: pre-commit-3|${{ hashFiles('.pre-commit-config.yaml') }}

- name: Run pre-commit
run: devbox run -- make pre-commit
run: devbox run -- task pre-commit:run
env:
SKIP: no-commit-to-branch,golangci-lint
SKIP: no-commit-to-branch,golangci-lint,actionlint-system

govulncheck:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Install devbox
uses: jetpack-io/[email protected]
with:
enable-cache: true

- id: govulncheck
run: devbox run -- task go:vulncheck
5 changes: 4 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
schedule:
- cron: '32 21 * * 2'

env:
TASK_X_ANY_VARIABLES: 1

jobs:
analyze:
name: Analyze
Expand Down Expand Up @@ -39,7 +42,7 @@ jobs:
enable-cache: true

- name: Build
run: devbox run -- make build-snapshot
run: devbox run -- task build:snapshot

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
4 changes: 4 additions & 0 deletions .github/workflows/dependabot-automation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ permissions:
pull-requests: write
contents: write

defaults:
run:
shell: bash

jobs:
enable-automerge:
runs-on: ubuntu-22.04
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/devbox-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,11 @@ jobs:

- name: Create PR using app token
if: steps.devbox-versions-changed.outputs.number_changed > 0
id: create-pr
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
pr_url="$(gh pr create --base "${{ github.ref_name }}" --head "${DESTINATION_BRANCH}" \
--title "${{ steps.commit-changes.outputs.message }}" \
--body "This PR was automatically created by the scheduled devbox update workflow.")"
pr_url="$(gh pr create --base '${{ github.ref_name }}' --head "${DESTINATION_BRANCH}" \
--title '${{ steps.commit-changes.outputs.message }}' \
--body 'This PR was automatically created by the scheduled devbox update workflow.' \
--label ignore-for-release)"
gh pr merge --auto --squash "${pr_url}"
echo "pr_url=${pr_url}" >>"${GITHUB_OUTPUT}"
20 changes: 0 additions & 20 deletions .github/workflows/recover-secret.yaml

This file was deleted.

12 changes: 8 additions & 4 deletions .github/workflows/release-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ permissions:
contents: write
packages: write

defaults:
run:
shell: bash

env:
TASK_X_ANY_VARIABLES: 1

jobs:
release-tag:
runs-on: ubuntu-22.04
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -31,6 +35,6 @@ jobs:
enable-cache: true

- name: Release
run: devbox run -- make release
run: devbox run -- task build:release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ dist/

*.tar.gz
*.tar

.task
.devbox
12 changes: 9 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,17 @@ repos:
stages: [commit]
- id: end-of-file-fixer
stages: [commit]
- repo: https://github.com/rhysd/actionlint
rev: v1.6.25
hooks:
- id: actionlint-system
stages: [commit]
- repo: https://github.com/jorisroovers/gitlint
rev: v0.19.1
hooks:
- id: gitlint
stages: [commit-msg]
- id: gitlint-ci
args: ["--commits", "origin/main..HEAD"]
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
Expand Down Expand Up @@ -74,9 +80,9 @@ repos:
- //
- --allow-past-years
- id: insert-license
name: License headers - YAML and Makefiles
name: License headers - YAML
stages: [commit]
files: (^Makefile|\.(ya?ml|mk))$
files: \.ya?ml$
args:
- --license-filepath
- header.txt
Expand Down
12 changes: 11 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
{
"go.buildTags": "e2e",
"ginkgotestexplorer.buildTags": "e2e"
"ginkgotestexplorer.buildTags": "e2e",
"yaml.schemas": {
"https://taskfile.dev/schema.json": [
"tasks/build.yaml",
"tasks/repo.yaml",
"tasks/git.yaml",
"tasks/pre-commit.yaml",
"tasks/go.yaml",
"tasks/test.yaml"
]
}
}
6 changes: 0 additions & 6 deletions Makefile

This file was deleted.

17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,10 @@ Install direnv: <https://direnv.net/docs/installation.html#from-system-packages>

Hook direnv into your shell if you haven't already: <https://direnv.net/docs/hook.html>.

### Configure global go mod cache

By default `devenv` will use an isolated go mod cache for each project which is great from an isolation point of view,
but terrible for disk space (duplication!). To configure a global go mod cache, add the following after the `direnv`
integration above to your shell config file, adapting the path as appropriate:

```bash
export GOMODCACHE=~/go/pkg/mod
```

## Building the CLI

Build the CLI using `make build-snapshot` that will output binary into
`dist/mindthegap_$(GOOS)_$(GOARCH)/mindthegap` and put it in `$PATH`.
`mindthegap` uses [`task`](https://taskfile.dev/) for running build tasks. `task` will be automatically available when
the devbox environment is correctly set up.

Build the CLI using `task build:snapshot` that will output binary into
`./dist/mindthegap_$(GOOS)_$(GOARCH)/mindthegap`.
16 changes: 16 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 D2iQ, Inc. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

version: '3'

set:
- errexit
- nounset
- pipefail

includes:
build: ./tasks/build.yaml
git: ./tasks/git.yaml
pre-commit: ./tasks/pre-commit.yaml
go: ./tasks/go.yaml
test: ./tasks/test.yaml
Loading
Loading