Skip to content

Commit

Permalink
build: add separate build runs in check gh action
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard committed Feb 14, 2024
1 parent 728dcec commit 36bd0b0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 51 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/check-code-and-unit-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ jobs:
;;
core)
ARGS+=" //core/api:test"
BUILD_ARGS+=" //core/api:tsc_build_context"
BUILD_ARGS+=" //core/api:eslint_build_context"
BUILD_ARGS+=" //core/api:typescript_build_context"
BUILD_ARGS+=" //core/api:yaml_build_context"
BUILD_ARGS+=" //core/api:madge_build_context"
BUILD_ARGS+=" //core/api:jest_build_context"
BUILD_ARGS+=" //core/api:prod_build"
;;
api-keys|notifications)
Expand Down
43 changes: 37 additions & 6 deletions core/api/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ prod_deps_srcs = {
"lib/gt3-server-node-express-sdk": "//lib/gt3-server-node-express-sdk:src",
}

prepare_build_context(
name = "tsc_build_context",
srcs = [":src"],
prod_deps_srcs = prod_deps_srcs,
)

tsc_build(
name = "build",
tsconfig = "tsconfig-build.json",
Expand Down Expand Up @@ -132,17 +138,16 @@ dev_update_file(
out = "src/graphql/admin/schema.graphql"
)

prepare_build_context(
name = "checks_build_context",
srcs = [":src"] + [":test_src"],
prod_deps_srcs = prod_deps_srcs,
)

audit(
name = "audit",
level = "critical",
)

prepare_build_context(
name = "eslint_build_context",
srcs = [":src"] + [":test_src"] + glob([".eslint*"]),
)

eslint(
name = "check-lint",
srcs = [":src"] + [":test_src"] + glob([".eslint*"]),
Expand All @@ -155,6 +160,11 @@ dev_pnpm_task_test(
command = "eslint-check",
)

prepare_build_context(
name = "typescript_build_context",
srcs = [":src"] + [":test_src"],
)

typescript_check(
name = "check-type",
srcs = [":src"] + [":test_src"],
Expand All @@ -165,6 +175,16 @@ dev_pnpm_task_test(
command = "tsc-check",
)

prepare_build_context(
name = "yaml_build_context",
srcs = glob([
".prettier*",
"prettier*",
"*.yml",
"*.yaml",
]),
)

yaml_check(
name = "check-yaml",
srcs = glob([
Expand All @@ -175,6 +195,11 @@ yaml_check(
]),
)

prepare_build_context(
name = "madge_build_context",
srcs = [":src"],
)

madge_check(
name = "check-circular-dependencies",
srcs = [":src"],
Expand All @@ -185,6 +210,12 @@ dev_pnpm_task_test(
command = "circular-deps-check",
)

prepare_build_context(
name = "jest_build_context",
srcs = [":src"] + [":test_src"] + glob([".env", "galoy.yaml"]),
prod_deps_srcs = prod_deps_srcs,
)

jest_test(
name = "unit-tests",
srcs = [":src"] + [":test_src"] + glob([".env", "galoy.yaml"]),
Expand Down
57 changes: 12 additions & 45 deletions toolchains/workspace-pnpm/macros.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,8 @@ def tsc_build_impl(ctx: AnalysisContext) -> list[DefaultInfo]:

def tsc_build(
node_modules = ":node_modules",
build_context = ":tsc_build_context",
**kwargs):
build_context = "tsc_build_context"
if not rule_exists(build_context):
prepare_build_context(
name = build_context,
srcs = kwargs["srcs"],
prod_deps_srcs = kwargs.get("prod_deps_srcs", {}),
)
tsc_bin = "tsc_bin"
if not rule_exists(tsc_bin):
npm_bin(
Expand All @@ -241,7 +235,7 @@ def tsc_build(
tsc = ":{}".format(tsc_bin),
tscpaths = ":{}".format(tscpaths_bin),
node_modules = node_modules,
build_context = ":{}".format(build_context),
build_context = build_context,
**kwargs,
)

Expand Down Expand Up @@ -865,15 +859,9 @@ _eslint = rule(
def eslint(
eslint_bin = "eslint",
node_modules = ":node_modules",
build_context = ":eslint_build_context",
visibility = ["PUBLIC"],
**kwargs):
build_context = "eslint_build_context"
if not rule_exists(build_context):
prepare_build_context(
name = build_context,
srcs = kwargs["srcs"],
dev_deps_srcs = kwargs.get("dev_deps_srcs", {}),
)
if not rule_exists(eslint_bin):
npm_bin(
name = eslint_bin,
Expand All @@ -883,7 +871,7 @@ def eslint(
_eslint(
eslint = ":{}".format(eslint_bin),
node_modules = node_modules,
build_context = ":{}".format(build_context),
build_context = build_context,
visibility = visibility,
**kwargs,
)
Expand Down Expand Up @@ -955,14 +943,9 @@ _typescript_check = rule(

def typescript_check(
node_modules = ":node_modules",
build_context = ":typescript_build_context",
visibility = ["PUBLIC"],
**kwargs):
build_context = "typescript_build_context"
if not rule_exists(build_context):
prepare_build_context(
name = build_context,
srcs = kwargs["srcs"],
)
tsc_bin = "tsc_bin"
if not rule_exists(tsc_bin):
npm_bin(
Expand All @@ -973,7 +956,7 @@ def typescript_check(
_typescript_check(
tsc = ":{}".format(tsc_bin),
node_modules = node_modules,
build_context = ":{}".format(build_context),
build_context = build_context,
visibility = visibility,
**kwargs,
)
Expand Down Expand Up @@ -1040,14 +1023,9 @@ _yaml_check = rule(

def yaml_check(
node_modules = ":node_modules",
build_context = ":yaml_build_context",
visibility = ["PUBLIC"],
**kwargs):
build_context = "yaml_build_context"
if not rule_exists(build_context):
prepare_build_context(
name = build_context,
srcs = kwargs["srcs"],
)
prettier_bin = "prettier_bin"
if not rule_exists(prettier_bin):
npm_bin(
Expand All @@ -1058,7 +1036,7 @@ def yaml_check(
_yaml_check(
prettier = ":{}".format(prettier_bin),
node_modules = node_modules,
build_context = ":{}".format(build_context),
build_context = build_context,
visibility = visibility,
**kwargs,
)
Expand Down Expand Up @@ -1127,14 +1105,9 @@ _madge_check = rule(

def madge_check(
node_modules = ":node_modules",
build_context = ":madge_build_context",
visibility = ["PUBLIC"],
**kwargs):
build_context = "madge_build_context"
if not rule_exists(build_context):
prepare_build_context(
name = build_context,
srcs = kwargs["srcs"],
)
madge_bin = "madge_bin"
if not rule_exists(madge_bin):
npm_bin(
Expand All @@ -1145,7 +1118,7 @@ def madge_check(
_madge_check(
madge = ":{}".format(madge_bin),
node_modules = node_modules,
build_context = ":{}".format(build_context),
build_context = build_context,
visibility = visibility,
**kwargs,
)
Expand Down Expand Up @@ -1314,15 +1287,9 @@ _jest_test = rule(

def jest_test(
node_modules = ":node_modules",
build_context = ":jest_build_context",
visibility = ["PUBLIC"],
**kwargs):
build_context = "jest_build_context"
if not rule_exists(build_context):
prepare_build_context(
name = build_context,
srcs = kwargs["srcs"],
prod_deps_srcs = kwargs.get("prod_deps_srcs", {}),
)
jest_bin = "jest_bin"
if not rule_exists(jest_bin):
npm_bin(
Expand All @@ -1333,7 +1300,7 @@ def jest_test(
_jest_test(
jest = ":{}".format(jest_bin),
node_modules = node_modules,
build_context = ":{}".format(build_context),
build_context = build_context,
visibility = visibility,
**kwargs,
)

0 comments on commit 36bd0b0

Please sign in to comment.