Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Fix build pipeline (#66)
Browse files Browse the repository at this point in the history
* Deletes artifacts from previous builds
* Fixes missing Teleport-E files
* Fixes invalid SHA lookup code.
  • Loading branch information
alex-kovoy authored Apr 7, 2020
1 parent d9c2906 commit 4dfef4e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
44 changes: 24 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ COMMIT_URL = https://github.com/gravitational/webapps/commit/$(COMMIT)
.PHONY: build
build:
@if [ -d "packages/webapps.e/" ]; then \
$(MAKE) docker-build NPM_CMD=build-all FROM=dist/ TO=dist/; \
$(MAKE) docker-build NPM_CMD=build FROM=dist/ TO=dist/; \
else \
$(MAKE) docker-build NPM_CMD=build-oss FROM=dist/ TO=dist/; \
fi;
Expand All @@ -23,21 +23,25 @@ test:
build-force:
$(MAKE) docker-build NPM_CMD=build-force FROM=dist/force/ TO=dist/force

.PHONY: build-gravity
build-gravity:
$(MAKE) docker-build NPM_CMD=build-gravity FROM=dist/gravity/ TO=dist/gravity
.PHONY: build-gravity-oss
build-gravity-oss:
$(MAKE) docker-build NPM_CMD=build-gravity-oss FROM=dist/gravity/ TO=dist/gravity

.PHONY: build-teleport
build-teleport:
$(MAKE) docker-build NPM_CMD=build-teleport FROM=dist/teleport/ TO=dist/teleport
.PHONY: build-teleport-oss
build-teleport-oss:
$(MAKE) docker-build NPM_CMD=build-teleport-oss FROM=dist/teleport/ TO=dist/teleport

.PHONY: build-gravity-e
build-gravity-e:
$(MAKE) docker-build NPM_CMD=build-gravity-e FROM=dist/e/gravity/ TO=dist/e/gravity;

.PHONY: build-teleport-e
build-teleport-e:
$(MAKE) docker-build NPM_CMD=build-teleport-e; FROM=dist/e/teleport/ TO=dist/e/teleport;
$(MAKE) docker-build NPM_CMD=build-teleport-e FROM=dist/e/teleport/ TO=dist/e/teleport;

.PHONY: build-teleport
build-teleport:
$(MAKE) docker-build NPM_CMD=build-teleport FROM=dist/ TO=dist/;

# builds package dists files in docker (TODO: move it to scripts/docker-build.sh)
.PHONY: docker-build
Expand All @@ -60,33 +64,33 @@ docker-enter:
docker-clean:
docker rmi --force $(IMAGE_NAME)

# update webassets repository with the new /dist files
.PHONY: update-webassets-repo
update-webassets-repo:
# update teleport repository with build assets
.PHONY: update-teleport-repo
update-teleport-repo:
@if [ -z "$(TELEPORT_TARGET)" ]; then \
echo "TELEPORT_TARGET is not set"; exit 1; \
fi
# prepare webassets repo
rm -rf dist && git clone git@github.com:gravitational/webassets.git dist
cd dist; git checkout $(BRANCH) || git checkout -b $(BRANCH)
cd dist; rm -fr */
# prepare webassets.e repo
cd dist; git submodule update --init --recursive
cd dist/e; git checkout $(BRANCH) || git checkout -b $(BRANCH)
# prepare teleport repo
echo teleport >> .gitignore
rm -rf teleport && git clone git@github.com:gravitational/teleport.git
cd teleport; git checkout $(TELEPORT_TARGET) || git checkout -b $(TELEPORT_TARGET)
cd teleport; git fetch --recurse-submodules && git submodule update --init webassets
cd dist/e; rm -fr */
# build the dist files
$(MAKE) build
$(MAKE) build-teleport
# push dist files to webasset/e repositories
cd dist/e; git add -A .; git commit -am '$(COMMIT_DESC)' -m '$(COMMIT_URL)' --allow-empty; git push origin $(BRANCH)
cd dist; git add -A .; git commit -am '$(COMMIT_DESC)' -m '$(COMMIT_URL)' --allow-empty; git push origin $(BRANCH)
# use temporary file to store commit sha
# use temporary file to store new webassets commit sha
cd dist; git rev-parse HEAD >> commit_sha;
$(eval WEBAPPS_HEAD=$(shell cat dist/commit_sha))
# update teleport
cd teleport/webassets; git checkout $(WEBAPPS_HEAD)
echo teleport >> .gitignore
rm -rf teleport && git clone git@github.com:gravitational/teleport.git
cd teleport; git checkout $(TELEPORT_TARGET) || git checkout -b $(TELEPORT_TARGET)
cd teleport; git fetch --recurse-submodules && git submodule update --init webassets
cd teleport/webassets; git checkout $$(cat -v ../../dist/commit_sha)
cd teleport; git add -A .; git commit -am 'Update webassets' -m '$(COMMIT_DESC) $(COMMIT_URL)' --allow-empty
cd teleport; git push origin $(TELEPORT_TARGET)

Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
"start-gravity-e": "yarn workspace @gravitational/gravity.e start",
"start-teleport-e": "yarn workspace @gravitational/teleport.e start",
"build-force": "yarn workspace @gravitational/force build --output-path=../../dist/force/app",
"build-gravity": "yarn workspace @gravitational/gravity build --output-path=../../dist/gravity/app",
"build-teleport": "yarn workspace @gravitational/teleport build --output-path=../../dist/teleport/app",
"build-gravity": "yarn build-gravity && yarn build-gravity-e",
"build-gravity-e": "yarn workspace @gravitational/gravity.e build --output-path=../../../dist/e/gravity/app",
"build-teleport-e": "yarn workspace @gravitational/teleport.e build --output-path=../../dist/e/teleport/app",
"build-oss": "yarn build-force && yarn build-teleport && yarn build-gravity",
"build-gravity-oss": "yarn workspace @gravitational/gravity build --output-path=../../dist/gravity/app",
"build-teleport": "yarn build-teleport-oss && yarn build-teleport-e",
"build-teleport-oss": "yarn workspace @gravitational/teleport build --output-path=../../dist/teleport/app",
"build-teleport-e": "yarn workspace @gravitational/teleport.e build --output-path=../../../dist/e/teleport/app",
"build-oss": "yarn build-force && yarn build-teleport-oss && yarn build-gravity-oss",
"build-e": "yarn build-teleport-e && yarn build-gravity-e",
"build-all": "yarn type-check; yarn build-oss && yarn build-e",
"build": "yarn type-check; yarn build-oss && yarn build-e",
"type-check": "yarn tsc"
},
"private": true,
Expand Down

0 comments on commit 4dfef4e

Please # to comment.