Skip to content

Commit d8524de

Browse files
authored
Merge branch 'main' into feat/officers-cli
2 parents 1c3c3d3 + 1b185b1 commit d8524de

5 files changed

Lines changed: 72 additions & 56 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,32 @@ jobs:
2323
- "**/*.sql"
2424
- "go.mod"
2525
- "go.sum"
26+
- "Makefile"
2627
2728
- name: Install Nix
2829
if: steps.filter.outputs.source_code == 'true'
2930
uses: DeterminateSystems/nix-installer-action@main
3031

3132
- name: Format check
3233
if: steps.filter.outputs.source_code == 'true'
33-
run: nix develop -c bash -c "make fmt && git diff --exit-code"
34+
run: nix develop .#ci -c bash -c "make fmt && git diff --exit-code"
3435

3536
- name: Check
3637
if: steps.filter.outputs.source_code == 'true'
37-
run: nix develop -c make check
38+
run: nix develop .#ci -c make check
3839

3940
- name: Sql check
4041
if: steps.filter.outputs.source_code == 'true'
41-
run: nix develop -c make check-sql
42+
run: nix develop .#ci -c make check-sql
4243

4344
- name: Build
4445
if: steps.filter.outputs.source_code == 'true'
45-
run: nix develop -c make build
46+
run: nix develop .#ci -c make build
47+
48+
- name: Generated files check
49+
if: steps.filter.outputs.source_code == 'true'
50+
run: nix develop .#ci -c bash -c "make generate && git diff --exit-code"
4651

4752
- name: Test
4853
if: steps.filter.outputs.source_code == 'true'
49-
run: nix develop -c make test
54+
run: nix develop .#ci -c make test

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ GO_DEPS := $(GO_SOURCES) go.mod go.sum
1010
MIGRATE_DIR := sql/migrations
1111
DB_URL := sqlite3://dev.db
1212

13-
DOCS_DEPS := $(wildcard internal/api/handlers/*.go)
14-
DOCS_TARGET := internal/api/docs/docs.go
1513
SQLC_DEPS := $(wildcard sql/migrations/*.sql) $(wildcard sql/queries/*.sql)
1614
SQLC_TARGET := internal/api/dbmodels/models.go
1715

@@ -25,7 +23,7 @@ build: api cli ## Build the api and cli binaries
2523

2624
api: $(BIN_DIR)/$(API_NAME) ## Build the api binary
2725

28-
$(BIN_DIR)/$(API_NAME): $(GO_DEPS) $(SQLC_TARGET)
26+
$(BIN_DIR)/$(API_NAME): $(GO_DEPS) sqlc
2927
@mkdir -p $(BIN_DIR)
3028
go build -ldflags "-X main.Version=$(VERSION)" -o $(BIN_DIR)/$(API_NAME) ./cmd/$(API_NAME)
3129

@@ -35,19 +33,21 @@ $(BIN_DIR)/$(CLI_NAME): $(GO_DEPS)
3533
@mkdir -p $(BIN_DIR)
3634
go build -ldflags "-X cli.Version=$(VERSION)" -o $(BIN_DIR)/$(CLI_NAME) ./cmd/$(CLI_NAME)
3735

38-
generate: $(DOCS_TARGET) $(SQLC_TARGET) ## Generate all necessary files with
36+
generate: swag sqlc ## Generate all necessary files
3937

40-
$(DOCS_TARGET): $(DOCS_DEPS)
38+
swag: ## Generate OpenAPI docs
4139
swag init -d cmd/acmcsuf-api,internal/api/handlers,internal/api/dbmodels -o internal/api/docs --parseDependency
4240

41+
sqlc: $(SQLC_TARGET) ## Generate dbmodels package with sqlc
42+
4343
$(SQLC_TARGET): $(SQLC_DEPS)
4444
sqlc generate
4545

4646
fmt: ## Format all go files
4747
@go fmt ./...
4848

4949
check: ## Run static analysis on all go files
50-
staticcheck -f stylish ./...
50+
staticcheck -f stylish ./...
5151

5252
test: check ## Run all tests
5353
go test ./...

flake.nix

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,26 @@
2323
package = pkgs.callPackage ./nix/package.nix {
2424
version = version;
2525
};
26-
2726
acmcsuf-api = {
2827
type = "app";
2928
program = "${package}/bin/acmcsuf-api";
3029
};
30+
acmcsuf-cli = {
31+
type = "app";
32+
program = "${package}/bin/acmcsuf-cli";
33+
};
3134
in {
32-
packages.default = package;
33-
devShells.default = pkgs.callPackage ./nix/shell.nix {};
35+
devShells = {
36+
default = pkgs.callPackage ./nix/shell.nix {};
37+
full = pkgs.callPackage ./nix/shell.nix {full = true;};
38+
ci = pkgs.callPackage ./nix/shell.nix {isCI = true;};
39+
};
3440

41+
packages.default = package;
3542
apps = {
3643
default = acmcsuf-api;
3744
acmcsuf-api = acmcsuf-api;
38-
acmcsuf-cli = {
39-
type = "app";
40-
program = "${package}/bin/acmcsuf-cli";
41-
};
45+
acmcsuf-cli = acmcsuf-cli;
4246
};
4347
}
4448
);

nix/package.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
buildGoModule,
55
}:
66
buildGoModule {
7-
name = "acmcsuf-api";
7+
pname = "acmcsuf-api";
88
src = ../.;
99
version = version;
10-
vendorHash = "sha256-qr5wgHUKVv+Sv7TQGgOX9zRx9O6OgqFA16xwBTSysb4=";
10+
vendorHash = "sha256-XCzKPPjCbO2Kp9XGZ94PpPedyJhFAs+ys+gna66jDSE=";
1111
subPackages = ["cmd/acmcsuf-api" "cmd/acmcsuf-cli"];
1212
ldflags = ["-X main.Version=${version}"];
1313

nix/shell.nix

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,61 @@
11
{
22
mkShell,
3+
lib,
34
go,
45
gopls,
56
delve,
67
sqlc,
78
air,
89
sqlfluff,
910
gnumake,
10-
curl,
1111
xh,
12-
jq,
1312
go-swag,
1413
cobra-cli,
1514
go-tools,
1615
go-migrate,
1716
sqlite,
1817
sqlite-web,
19-
}:
20-
21-
let
22-
go-migrate-sqlite = go-migrate.overrideAttrs (oldAttrs: {
23-
tags = [ "sqlite3" ];
24-
});
18+
isCI ? false,
19+
full ? false,
20+
}: let
21+
go-migrate-sqlite = go-migrate.overrideAttrs (oldAttrs: {
22+
tags = ["sqlite3"];
23+
});
2524
in
26-
mkShell {
27-
packages = [
28-
go
29-
gopls # Go language server
30-
go-tools
31-
delve # Go debugger
32-
sqlc # compiles SQL queries to Go code
33-
air # run dev server with hot reload
34-
sqlfluff # SQL linter
35-
gnumake
36-
curl
37-
xh
38-
jq
39-
go-swag
40-
cobra-cli
41-
go-migrate-sqlite
42-
sqlite
43-
sqlite-web
44-
];
25+
mkShell {
26+
packages =
27+
[
28+
go
29+
gopls # Go language server
30+
go-tools
31+
sqlc # compiles SQL queries to Go code
32+
sqlfluff # SQL linter
33+
gnumake
34+
go-swag
35+
]
36+
# Dev tools not required in CI go here
37+
++ lib.optionals (!isCI) [
38+
air # run dev server with hot reload
39+
xh
40+
go-migrate-sqlite
41+
sqlite
42+
cobra-cli
43+
delve # Go debugger
44+
]
45+
# Heavyweight or rarely used tools go here
46+
++ lib.optionals full [
47+
sqlite-web
48+
];
49+
50+
env = {
51+
GOROOT = "${go}/share/go";
52+
};
4553

46-
shellHook = ''
47-
if [ ! -f .env ]; then
48-
echo ".env file not found! Creating one from .env.example for you..."
49-
cp .env.example .env
50-
fi
51-
echo -e "\e[32mLoaded nix dev shell\e[0m"
52-
export GOROOT="${go}/share/go"
53-
'';
54-
}
54+
shellHook = lib.optionalString (!isCI) ''
55+
if [ ! -f .env ]; then
56+
echo ".env file not found! Creating one from .env.example for you..."
57+
cp .env.example .env
58+
fi
59+
echo -e "\e[32mLoaded nix dev shell\e[0m"
60+
'';
61+
}

0 commit comments

Comments
 (0)