-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (53 loc) · 1.67 KB
/
Copy pathMakefile
File metadata and controls
65 lines (53 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
GO := go
BIN_DIR := bin
# Platform detection
ifeq ($(OS),Windows_NT)
BINARY_EXT := .exe
# Detect if we are in a Unix-like shell on Windows (e.g. Git Bash)
# If 'uname' is available, we assume a Unix-like shell
ifneq ($(shell uname -s 2>/dev/null),)
MKDIR_P := mkdir -p $(BIN_DIR)
RM_RF := rm -rf $(BIN_DIR)
else
MKDIR_P := if not exist $(BIN_DIR) mkdir $(BIN_DIR)
RM_RF := if exist $(BIN_DIR) rmdir /s /q $(BIN_DIR)
endif
else
BINARY_EXT :=
MKDIR_P := mkdir -p $(BIN_DIR)
RM_RF := rm -rf $(BIN_DIR)
SHELL := /bin/bash
endif
BIN := $(BIN_DIR)/pmg$(BINARY_EXT)
GITCOMMIT := $(shell git rev-parse HEAD)
VERSION := "$(shell git describe --tags --abbrev=0)-$(shell git rev-parse --short HEAD)"
GO_CFLAGS=-X 'github.com/safedep/pmg/internal/version.Commit=$(GITCOMMIT)' -X 'github.com/safedep/pmg/internal/version.Version=$(VERSION)'
GO_LDFLAGS=-ldflags "-w $(GO_CFLAGS)"
.PHONY: all pmg create_bin clean test sandbox-e2e
all: pmg
pmg: create_bin
$(GO) build ${GO_LDFLAGS} -o $(BIN) main.go
create_bin:
$(MKDIR_P)
clean:
$(RM_RF)
test:
$(GO) test ./...
# Runs the sandbox E2E tests with seeded env canaries, mirroring the
# pmg-e2e.yml sandbox jobs. Requires node and a supported sandbox driver
# (Seatbelt on macOS, Bubblewrap or Landlock on Linux).
sandbox-e2e: pmg
E2E_ENV_SEEDED=1 \
GITHUB_TOKEN=pmg-e2e-canary \
gh_token=pmg-e2e-canary \
AWS_SECRET_ACCESS_KEY=pmg-e2e-canary \
OP_SERVICE_ACCOUNT_TOKEN=pmg-e2e-canary \
CLOUDFLARE_API_TOKEN=pmg-e2e-canary \
TWINE_PASSWORD=pmg-e2e-canary \
NPM_TOKEN=pmg-e2e-keep \
NODE_AUTH_TOKEN=pmg-e2e-keep \
./$(BIN) --sandbox --sandbox-enforce npm exec -- node ./test/sandbox-e2e.js
fmt:
$(GO) fmt ./...
lint:
golangci-lint run