Skip to content

Commit

Permalink
ci: Make builds marginally faster. Fixes #3515 (#3519)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed Jul 23, 2020
1 parent 38caab7 commit 94b2012
Show file tree
Hide file tree
Showing 16 changed files with 254 additions and 225 deletions.
19 changes: 5 additions & 14 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/cache@v1
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-v1-${{ github.run_id }}
key: ${{ runner.os }}-go-build-v1-${{ hashFiles('**/go.mod') }}
- name: Setup Golang
uses: actions/setup-go@v1
with:
Expand All @@ -35,6 +35,7 @@ jobs:
echo "::add-path::/home/runner/go/bin"
echo "::add-path::/usr/local/bin"
- name: Install Kustomize
if: ${{ matrix.test != 'test' }}
run: |
cd /usr/local/bin && curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | sudo bash
kustomize version
Expand All @@ -46,9 +47,6 @@ jobs:
env:
GOPATH: /home/runner/go
run: make pull-build-images test-images &
- name: Download all Go modules
run: |
go mod download
- name: Create Kubeconfig
if: ${{ matrix.test != 'test' }}
run: |
Expand Down Expand Up @@ -108,7 +106,7 @@ jobs:
uses: actions/cache@v1
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-build-v1-${{ github.run_id }}
key: ${{ runner.os }}-go-build-v1-${{ hashFiles('**/go.mod') }}
- name: Setup Golang
uses: actions/setup-go@v1
with:
Expand All @@ -117,9 +115,6 @@ jobs:
run: |
echo "::add-path::/home/runner/go/bin"
echo "::add-path::/usr/local/bin"
- name: Download all Go modules
run: |
go mod download
- name: Install Kustomize
run: |
cd /usr/local/bin && curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | sudo bash
Expand All @@ -142,11 +137,6 @@ jobs:
run: |
git fetch --tags
make codegen
- name: Make manifests
env:
GOPATH: /home/runner/go
run: |
make manifests
- name: Make lint
env:
GOPATH: /home/runner/go
Expand All @@ -170,9 +160,10 @@ jobs:
with:
path: ui/node_modules
key: ${{ runner.os }}-node-dep-v1-${{ hashFiles('**/yarn.lock') }}
- name: Install and Lint
- name: Install, build and Lint
run: |
yarn --cwd ui install
yarn --cwd ui build
yarn --cwd ui lint
- name: Ensure nothing changed
run: git diff --exit-code
1 change: 0 additions & 1 deletion .github/workflows/gh-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Deploy
on:
push:
branches:
- mkdocs
- master

jobs:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ git-ask-pass.sh
/pkg/apiclient/workflowarchive/workflow-archive.swagger.json
/pkg/apiclient/workflowtemplate/workflow-template.swagger.json
/site/
/node_modules/
5 changes: 0 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ linters:
linters-settings:
goimports:
local-prefixes: github.com/argoproj/argo
service:
golangci-lint-version: 1.23.8
project-path: github.com/argoproj/argo
prepare:
- make server/static/files.go CI=true
34 changes: 19 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ BUILD_DATE = $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GIT_COMMIT = $(shell git rev-parse HEAD)
GIT_REMOTE = origin
GIT_BRANCH = $(shell git rev-parse --symbolic-full-name --verify --quiet --abbrev-ref HEAD)
GIT_TAG = $(shell git describe --tags --abbrev=0)
GIT_TAG = $(shell git describe --always --tags --abbrev=0 || echo untagged)
GIT_TREE_STATE = $(shell if [ -z "`git status --porcelain`" ]; then echo "clean" ; else echo "dirty"; fi)

export DOCKER_BUILDKIT = 1

# To allow you to build with or without cache for debugging purposes.
DOCKER_BUILD_OPTS := --no-cache
# Use a different Dockerfile, e.g. for building for Windows or dev images.
DOCKERFILE := Dockerfile

Expand All @@ -35,7 +33,6 @@ endif

# If we are building dev images, then we want to use the Docker cache for speed.
ifeq ($(DEV_IMAGE),true)
DOCKER_BUILD_OPTS :=
DOCKERFILE := Dockerfile.dev
endif

Expand Down Expand Up @@ -109,7 +106,7 @@ UI_FILES := $(shell find ui/src -type f && find ui -maxdepth 1 -type f)
define docker_build
# If we're making a dev build, we build this locally (this will be faster due to existing Go build caches).
if [ $(DEV_IMAGE) = true ]; then $(MAKE) dist/$(2)-$(OUTPUT_IMAGE_OS)-$(OUTPUT_IMAGE_ARCH) && mv dist/$(2)-$(OUTPUT_IMAGE_OS)-$(OUTPUT_IMAGE_ARCH) $(2); fi
docker build --progress plain $(DOCKER_BUILD_OPTS) -t $(IMAGE_NAMESPACE)/$(1):$(VERSION) --target $(1) -f $(DOCKERFILE) --build-arg IMAGE_OS=$(OUTPUT_IMAGE_OS) --build-arg IMAGE_ARCH=$(OUTPUT_IMAGE_ARCH) .
docker build --progress plain -t $(IMAGE_NAMESPACE)/$(1):$(VERSION) --target $(1) -f $(DOCKERFILE) --build-arg IMAGE_OS=$(OUTPUT_IMAGE_OS) --build-arg IMAGE_ARCH=$(OUTPUT_IMAGE_ARCH) .
if [ $(DEV_IMAGE) = true ]; then mv $(2) dist/$(2)-$(OUTPUT_IMAGE_OS)-$(OUTPUT_IMAGE_ARCH); fi
if [ $(K3D) = true ]; then k3d import-images $(IMAGE_NAMESPACE)/$(1):$(VERSION); fi
touch $(3)
Expand All @@ -120,14 +117,18 @@ define docker_pull
endef

.PHONY: build
build: status clis executor-image controller-image manifests/install.yaml manifests/namespace-install.yaml manifests/quick-start-postgres.yaml manifests/quick-start-mysql.yaml
build: status clis images manifests

.PHONY: images
images: cli-image executor-image controller-image

# https://stackoverflow.com/questions/4122831/disable-make-builtin-rules-and-variables-from-inside-the-make-file
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:

.PHONY: status
status:
# GIT_TAG=$(GIT_TAG), GIT_BRANCH=$(GIT_BRANCH), GIT_TREE_STATE=$(GIT_TREE_STATE), VERSION=$(VERSION), VERSION=$(VERSION), DEV_IMAGE=$(DEV_IMAGE), K3D=$(K3D)
# GIT_TAG=$(GIT_TAG), GIT_BRANCH=$(GIT_BRANCH), GIT_TREE_STATE=$(GIT_TREE_STATE), VERSION=$(VERSION), DEV_IMAGE=$(DEV_IMAGE), K3D=$(K3D)

# cli

Expand Down Expand Up @@ -217,8 +218,8 @@ dist/argoexec-%: $(ARGOEXEC_PKGS)
.PHONY: executor-image
executor-image: $(EXECUTOR_IMAGE_FILE)

# Create executor image
$(EXECUTOR_IMAGE_FILE): $(ARGOEXEC_PKGS)
# Create executor image
$(call docker_build,argoexec,argoexec,$(EXECUTOR_IMAGE_FILE))

# generation
Expand Down Expand Up @@ -285,7 +286,7 @@ manifests: crds
# lint/test/etc

$(GOPATH)/bin/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b `go env GOPATH`/bin v1.23.8
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b `go env GOPATH`/bin v1.27.0

.PHONY: lint
lint: server/static/files.go $(GOPATH)/bin/golangci-lint
Expand Down Expand Up @@ -385,19 +386,19 @@ mysql-cli:
kubectl exec -ti `kubectl get pod -l app=mysql -o name|cut -c 5-` -- mysql -u mysql -ppassword argo

.PHONY: test-e2e
test-e2e: test-images cli
test-e2e:
# Run E2E tests
@mkdir -p test-results
go test -timeout 15m -v -count 1 --tags e2e -p 1 --short ./test/e2e 2>&1 | tee test-results/test.out

.PHONY: test-e2e-cron
test-e2e-cron: test-images cli
test-e2e-cron:
# Run E2E tests
@mkdir -p test-results
go test -timeout 5m -v -count 1 --tags e2e -parallel 10 -run CronSuite ./test/e2e 2>&1 | tee test-results/test.out

.PHONY: smoke
smoke: test-images
smoke:
# Run smoke tests
@mkdir -p test-results
go test -timeout 1m -v -count 1 --tags e2e -p 1 -run SmokeSuite ./test/e2e 2>&1 | tee test-results/test.out
Expand Down Expand Up @@ -455,9 +456,12 @@ api/openapi-spec/swagger.json: dist/kubeified.swagger.json
swagger validate api/openapi-spec/swagger.json
go test ./api/openapi-spec

docs/swagger.md:
npm install -g swagger-markdown
swagger-markdown -i api/openapi-spec/swagger.json -o docs/swagger.md

./node_modules/.bin/swagger-markdown:
npm install swagger-markdown

docs/swagger.md: api/openapi-spec/swagger.json ./node_modules/.bin/swagger-markdown
./node_modules/.bin/swagger-markdown -i api/openapi-spec/swagger.json -o docs/swagger.md

.PHONY: docs
docs: api/openapi-spec/swagger.json docs/swagger.md
Expand Down

0 comments on commit 94b2012

Please sign in to comment.