Skip to content

Commit

Permalink
feat: upgrade under nix
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag committed Jan 22, 2025
1 parent e6b9865 commit 6708f71
Show file tree
Hide file tree
Showing 500 changed files with 23,633 additions and 165 deletions.
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use flake --impure
dotenv
32 changes: 9 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dirty:
runs-on: "ubuntu-latest"
runs-on: "formance-runner"
steps:
- uses: 'actions/checkout@v4'
with:
Expand All @@ -35,11 +35,8 @@ jobs:
with:
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
- run: >
earthly
--allow-privileged
--secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY
${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }}
+pre-commit
/nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes"
develop --impure --command just pre-commit
env:
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
- name: Get changed files
Expand All @@ -54,7 +51,7 @@ jobs:
fi
Tests:
runs-on: "ubuntu-latest"
runs-on: "formance-runner"
needs:
- Dirty
steps:
Expand All @@ -66,17 +63,13 @@ jobs:
with:
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
- 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
/nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes"
develop --impure --command just tests
env:
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
GoReleaser:
runs-on: "ubuntu-latest"
runs-on: "formance-runner"
if: contains(github.event.pull_request.labels.*.name, 'build-images') || github.ref == 'refs/heads/main' || github.event_name == 'merge_group'
needs:
- Dirty
Expand All @@ -89,15 +82,8 @@ jobs:
with:
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
- run: >
earthly
--no-output
--allow-privileged
--secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY
--secret GITHUB_TOKEN=$GITHUB_TOKEN
--secret FURY_TOKEN=$FURY_TOKEN
--secret GORELEASER_KEY=$GORELEASER_KEY
${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }}
+release --mode=ci
/nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes"
develop --impure --command just release-ci
env:
GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
Expand Down
20 changes: 4 additions & 16 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ permissions:

jobs:
GoReleaser:
runs-on: "ubuntu-latest"
runs-on: "formance-runner"
steps:
- uses: 'actions/checkout@v4'
with:
Expand All @@ -18,22 +18,10 @@ jobs:
with:
token: ${{ secrets.NUMARY_GITHUB_TOKEN }}
- run: >
earthly
--no-output
--allow-privileged
--secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY
--secret GITHUB_TOKEN=$GITHUB_TOKEN
--secret FURY_TOKEN=$FURY_TOKEN
--secret GORELEASER_KEY=$GORELEASER_KEY
${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }}
+release --mode=release
/nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes"
develop --impure --command just release
env:
GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Add the OpenAPI file to the release assets
run: >
gh release upload ${{github.ref_name}} ./openapi.yaml#openapi.yaml
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
vendor
orchestration
dist
4 changes: 3 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ release:
footer: |
## What to do next?
- Read the [documentation](https://docs.formance.com/)
- Join our [Slack server](https://formance.com/slack)
- Join our [Slack server](https://formance.com/slack)
extra_files:
- glob: ./openapi.yaml
36 changes: 0 additions & 36 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@ sources:
COPY main.go .
SAVE ARTIFACT /src

generate:
FROM core+builder-image
RUN apk update && apk add openjdk11
DO --pass-args core+GO_INSTALL --package=go.uber.org/mock/mockgen@latest
COPY (+sources/*) /src
WORKDIR /src
DO --pass-args core+GO_GENERATE
SAVE ARTIFACT internal AS LOCAL internal
SAVE ARTIFACT pkg AS LOCAL pkg
SAVE ARTIFACT cmd AS LOCAL cmd

compile:
FROM core+builder-image
COPY (+sources/*) /src
Expand All @@ -39,14 +28,6 @@ build-image:
ARG tag=latest
DO core+SAVE_IMAGE --COMPONENT=orchestration --REPOSITORY=${REPOSITORY} --TAG=$tag

tests:
FROM core+builder-image
COPY (+sources/*) /src
WORKDIR /src
WITH DOCKER --pull=postgres:15-alpine
DO --pass-args core+GO_TESTS
END

deploy:
COPY (+sources/*) /src
LET tag=$(tar cf - /src | sha1sum | awk '{print $1}')
Expand All @@ -59,23 +40,6 @@ deploy:
deploy-staging:
BUILD --pass-args core+deploy-staging

lint:
FROM core+builder-image
COPY (+sources/*) /src
COPY --pass-args +tidy/go.* .
WORKDIR /src
DO --pass-args core+GO_LINT
SAVE ARTIFACT cmd AS LOCAL cmd
SAVE ARTIFACT internal AS LOCAL internal
SAVE ARTIFACT pkg AS LOCAL pkg
SAVE ARTIFACT main.go AS LOCAL main.go

pre-commit:
WAIT
BUILD --pass-args +tidy
END
BUILD --pass-args +lint

openapi:
FROM node:20-alpine
RUN apk update && apk add yq
Expand Down
37 changes: 37 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
set dotenv-load

default:
@just --list

pre-commit: generate tidy lint
pc: pre-commit

lint:
@golangci-lint run --fix --build-tags it --timeout 5m

tidy:
@go mod tidy

generate:
@go generate ./...

tests:
@go test -race -covermode=atomic \
-coverprofile coverage.txt \
-tags it \
./...

openapi:
@yq eval-all '. as $item ireduce ({}; . * $item)' openapi/v1.yaml openapi/v2.yaml openapi/overlay.yaml > openapi.yaml

generate-client:
@speakeasy generate sdk -s openapi.yaml -o ./pkg/client -l go

release-local:
@goreleaser release --nightly --skip=publish --clean

release-ci:
@goreleaser release --nightly --clean

release:
@goreleaser release --clean
90 changes: 90 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6708f71

Please sign in to comment.