Skip to content

Commit

Permalink
feat: move a part of the tooling from earthfile to justfile (let depl…
Browse files Browse the repository at this point in the history
…oyment stuff for the moment) (#39)

* feat: move a part of the tooling from earthfile to justfile (let deployment stuff for the moment)

* feat: add missing files

* fix: wrong runners
  • Loading branch information
gfyrag authored Jan 20, 2025
1 parent ef61293 commit 15dcab3
Show file tree
Hide file tree
Showing 9 changed files with 244 additions and 98 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
36 changes: 9 additions & 27 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,13 +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
env:
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
/nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes"
develop --impure --command just pre-commit
- name: Get changed files
id: changed-files
shell: bash
Expand All @@ -54,7 +49,7 @@ jobs:
fi
Tests:
runs-on: "ubuntu-latest"
runs-on: "formance-runner"
needs:
- Dirty
steps:
Expand All @@ -66,17 +61,11 @@ 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
env:
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
/nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes"
develop --impure --command just tests
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 +78,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 --mode=ci
env:
GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
Expand Down
31 changes: 0 additions & 31 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ IMPORT github.com/formancehq/earthly:tags/v0.16.2 AS core
FROM core+base-image

sources:
WORKDIR src
WORKDIR /src
COPY go.* .
COPY --dir pkg cmd .
Expand All @@ -28,14 +27,6 @@ build-image:
ARG tag=latest
DO core+SAVE_IMAGE --COMPONENT=wallets --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 @@ -48,32 +39,10 @@ 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 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:
COPY ./openapi.yaml .
SAVE ARTIFACT ./openapi.yaml

tidy:
FROM core+builder-image
COPY --pass-args (+sources/src) /src
WORKDIR /src
DO --pass-args core+GO_TIDY

release:
FROM core+builder-image
ARG mode=local
Expand Down
30 changes: 30 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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 \
./...

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.

76 changes: 76 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
description = "Wallets dev env";

inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";

nur = {
url = "github:nix-community/NUR";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, nur }:
let
goVersion = 23;

supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];

forEachSupportedSystem = f:
nixpkgs.lib.genAttrs supportedSystems (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default nur.overlays.default ];
config.allowUnfree = true;
};
in
f { pkgs = pkgs; system = system; }
);

speakeasyVersion = "1.351.0";
speakeasyPlatforms = {
"x86_64-linux" = "linux_amd64";
"aarch64-linux" = "linux_arm64";
"x86_64-darwin" = "darwin_amd64";
"aarch64-darwin" = "darwin_arm64";
};
speakeasyHashes = {
"x86_64-linux" = "sha256-eeGzoIlsgsW/wnEET+UFgNN1qWgndxRHzulhHDTyHRY=";
"aarch64-linux" = "sha256-zOj2QUwLwRz0MyTLdVxLaGU7XEqhgKLCyhsO9S8VCNk=";
"x86_64-darwin" = "sha256-vBgEv6WWwJhBW6nMLy4Nj7qjWdGqk/4al5dIUCqrm1I=";
"aarch64-darwin" = "sha256-N129T0BDRVUXxH6Dl58/hUEApiq1q2B6qTwTuEjLDi4=";
};

in
{
overlays.default = final: prev: {
go = final."go_1_${toString goVersion}";
};

defaultPackage.x86_64-linux = self.packages.x86_64-linux.speakeasy;
defaultPackage.aarch64-linux = self.packages.aarch64-linux.speakeasy;
defaultPackage.x86_64-darwin = self.packages.x86_64-darwin.speakeasy;
defaultPackage.aarch64-darwin = self.packages.aarch64-darwin.speakeasy;

devShells = forEachSupportedSystem ({ pkgs, system }:
{
default = pkgs.mkShell {
packages = with pkgs; [
go
gotools
golangci-lint
ginkgo
pkgs.nur.repos.goreleaser.goreleaser-pro
just
];
};
}
);
};
}
Loading

0 comments on commit 15dcab3

Please sign in to comment.