Skip to content

Commit

Permalink
feat: add pre-commit and test targets to Earthfile
Browse files Browse the repository at this point in the history
- Introduce `tests` target in Earthfile for running Go tests.
- Add `.github/FUNDING.yml` to specify funding links.
- Update `.github/dependabot.yml` with new groups and configurations.
- Add `.github/actions/env/action.yml` for setting up environment.
- Introduce `.github/workflows/labeler.yml` for PR labeling.
- Update `.github/workflows/main.yml` with new job configurations.
  • Loading branch information
flemzord committed Sep 20, 2024
1 parent 0550c1b commit f4c48b5
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 56 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: FormanceHQ
20 changes: 20 additions & 0 deletions .github/actions/env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Setup Env
description: Setup Env for Linux x64
runs:
using: composite
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: "Put back the git branch into git (Earthly uses it for tagging)"
shell: bash
run: |
branch=""
if [ -n "$GITHUB_HEAD_REF" ]; then
branch="$GITHUB_HEAD_REF"
else
branch="${GITHUB_REF##*/}"
fi
git checkout -b "$branch" || true
26 changes: 22 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
version: 2
updates:

- package-ecosystem: "github-actions"
- package-ecosystem: gomod
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
interval: daily
open-pull-requests-limit: 40
labels: [ "dependencies" ]
# Groups are updated together in one pull request
groups:
otel:
patterns:
- "go.opentelemetry.io/otel*"
otel-collector:
patterns:
- "go.opentelemetry.io/collector*"
- "github.com/open-telemetry/o*-collector-contrib/*"
otel-instrumentation:
patterns:
- "go.opentelemetry.io/contrib/instrumentation/*"
go-openapi:
patterns:
- "github.com/go-openapi/*"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
labels: [ "dependencies" ]
33 changes: 0 additions & 33 deletions .github/workflows/codeql.yml

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Pull Request Labeler"
on:
pull_request_target:
types:
- opened
- reopened
- edited
- synchronize

jobs:
PR:
name: Check PR Title
runs-on: ubuntu-latest
permissions:
statuses: write
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60 changes: 54 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,60 @@
name: Default
on:
merge_group:
push:
branches:
- main
- releases/*
pull_request:
types: [ assigned, opened, synchronize, reopened, labeled ]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

name: Main
jobs:
lint:
uses: formancehq/gh-workflows/.github/workflows/golang-lint.yml@main
Dirty:
runs-on: "formance-runner"
steps:
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- name: Setup Env
uses: ./.github/actions/env
- run: >
earthly
--allow-privileged
--secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY
${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }}
+pre-commit
env:
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
- name: Get changed files
id: changed-files
shell: bash
run: |
hasChanged=$(git status --porcelain)
if (( $(echo ${#hasChanged}) != 0 )); then
git status
echo "There are changes in the repository"
exit 1
fi
test:
uses: formancehq/gh-workflows/.github/workflows/golang-test.yml@main
# Tests:
# runs-on: "formance-runner"
# needs:
# - Dirty
# steps:
# - uses: 'actions/checkout@v4'
# with:
# fetch-depth: 0
# - name: Setup Env
# uses: ./.github/actions/env
# - run: >
# earthly
# --no-output
# --allow-privileged
# --secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY
# ${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }}
# +tests
# env:
# SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
13 changes: 0 additions & 13 deletions .github/workflows/pr-open.yml

This file was deleted.

8 changes: 8 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ lint:
DO --pass-args core+GO_LINT
SAVE ARTIFACT /src AS LOCAL ./

tests:
FROM core+builder-image
WORKDIR /src
COPY --dir (+tidy/src/*) /src
WITH DOCKER
DO --pass-args core+GO_TESTS
END

pre-commit:
WAIT
BUILD --pass-args +tidy
Expand Down

0 comments on commit f4c48b5

Please sign in to comment.