Skip to content

Commit 9c83729

Browse files
authored
Update to build frontend without Bazel (#3572)
* Switch to build web without Bazel * Fix indent * Remove web-test from Kapetanios * Refactor
1 parent 36b5558 commit 9c83729

13 files changed

+71
-248
lines changed

.github/workflows/build.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ on:
88
branches:
99
- master
1010

11-
env:
12-
HELM_VERSION: 3.8.2
13-
1411
jobs:
1512
backend:
1613
name: Backend
@@ -40,7 +37,6 @@ jobs:
4037
- uses: actions/setup-node@v2
4138
with:
4239
node-version: '16.13.0'
43-
4440
- name: Get yarn cache directory path
4541
id: yarn-cache-dir-path
4642
run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -51,12 +47,17 @@ jobs:
5147
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
5248
restore-keys: |
5349
${{ runner.os }}-yarn-
50+
- name: Yarn install
51+
working-directory: web
52+
run: yarn install --prefer-offline
5453
- name: Build web static
55-
run: make build-frontend
54+
run: make web-build
5655

5756
chart:
5857
name: Helm Chart
5958
runs-on: ubuntu-latest
59+
env:
60+
HELM_VERSION: 3.8.2
6061
steps:
6162
- uses: actions/checkout@v2
6263
with:

.github/workflows/publish.yaml

+21-1
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,28 @@ jobs:
3939
run: make build-go GO_BUILD_COMPONENT=helloworld
4040

4141
# Building frontend.
42+
- uses: actions/setup-node@v2
43+
with:
44+
node-version: '16.13.0'
45+
- name: Get yarn cache directory path
46+
id: yarn-cache-dir-path
47+
run: echo "::set-output name=dir::$(yarn cache dir)"
48+
- uses: actions/cache@v2
49+
id: yarn-cache
50+
with:
51+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
52+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
53+
restore-keys: |
54+
${{ runner.os }}-yarn-
55+
- name: Yarn install
56+
working-directory: web
57+
run: yarn install
4258
- name: Build web static
43-
run: make build-frontend
59+
run: |
60+
make web-build
61+
rm -rf .artifacts/web-static
62+
mkdir -p .artifacts/web-static
63+
cp -rf web/dist/. .artifacts/web-static
4464
4565
# Login to push container images.
4666
- name: Log in to the container registry

.github/workflows/test.yaml

+2-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ jobs:
2828
- uses: actions/setup-node@v2
2929
with:
3030
node-version: '16.13.0'
31-
3231
- name: Get yarn cache directory path
3332
id: yarn-cache-dir-path
3433
run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -39,10 +38,8 @@ jobs:
3938
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
4039
restore-keys: |
4140
${{ runner.os }}-yarn-
42-
4341
- name: Yarn install
4442
working-directory: web
45-
run: yarn install
43+
run: yarn install --prefer-offline
4644
- name: Run unit tests
47-
working-directory: web
48-
run: echo "WIP"
45+
run: make web-test

.kapetanios/presubmit.yaml

-40
Original file line numberDiff line numberDiff line change
@@ -57,43 +57,3 @@ spec:
5757
secrets:
5858
- name: bazel_cache_service_account
5959
type: PROJECT
60-
61-
- name: web-test
62-
timeout: 30m
63-
whenChanged:
64-
- web/**
65-
steps:
66-
- name: restore-cache
67-
description: Restore node modules cache
68-
runner: kapetanios@restore-cache
69-
params:
70-
- key=node_modules
71-
- path=/workspace/.yarn
72-
- name: install-dependencies
73-
runner: gcr.io/kapetanios/node:16.13.1
74-
commands:
75-
- cd web
76-
- yarn install --frozen-lockfile
77-
- description: Save node modules cache
78-
runner: kapetanios@save-cache
79-
params:
80-
- key=node_modules
81-
- path=/workspace/.yarn
82-
- name: generate-client
83-
description: Generate API client code
84-
runner: gcr.io/pipecd/runner:1.0.0
85-
commands:
86-
- bazelisk --output_base=/workspace/bazel_out build --config=ci //web:build_api //web:build_model
87-
secrets:
88-
- name: bazel_cache_service_account
89-
type: PROJECT
90-
- name: test
91-
description: Run all web tests
92-
runner: gcr.io/kapetanios/node:16.13.1
93-
commands:
94-
- cd web
95-
- yarn test:coverage --coverageDirectory=/artifact --runInBand
96-
- yarn typecheck
97-
requires:
98-
- generate-client
99-
- install-dependencies

Makefile

+5-8
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ web-dep:
8686
web-dev:
8787
cd web; yarn dev
8888

89+
.PHONY: web-build
90+
web-build:
91+
cd web; yarn build
92+
8993
.PHONY: web-test
9094
web-test:
9195
cd web; yarn test:coverage --runInBand
@@ -131,14 +135,6 @@ update-docsy:
131135
codegen:
132136
docker run --rm -v ${PWD}:/repo -it gcr.io/pipecd/codegen:0.7.0 /repo
133137

134-
.PHONY: build-frontend
135-
build-frontend:
136-
rm -rf .artifacts/web-static
137-
mkdir -p .artifacts/web-static
138-
bazelisk ${BAZEL_FLAGS} build ${BAZEL_COMMAND_FLAGS} -- //web:static
139-
cp -rf bazel-bin/web/static/. .artifacts/web-static
140-
141-
142138
GO_BUILD_VERSION ?= $(shell git describe --tags --always --dirty --abbrev=7)
143139
GO_BUILD_COMMIT ?= $(shell git rev-parse HEAD)
144140
GO_BUILD_DATE ?= $(shell date -u '+%Y%m%d-%H%M%S')
@@ -157,3 +153,4 @@ package-chart: VERSION ?= $(shell git describe --tags --always --dirty --abbrev=
157153
package-chart:
158154
mkdir -p .artifacts
159155
helm package manifests/$(CHART) --version $(VERSION) --app-version $(VERSION) --dependency-update --destination .artifacts
156+

WORKSPACE

-33
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
workspace(
22
name = "pipecd",
3-
managed_directories = {"@npm": ["web/node_modules"]},
43
)
54

65
load(
@@ -87,36 +86,4 @@ load(
8786

8887
buildifier_dependencies()
8988

90-
### web
91-
92-
http_archive(
93-
name = "build_bazel_rules_nodejs",
94-
sha256 = "cfc289523cf1594598215901154a6c2515e8bf3671fd708264a6f6aefe02bf39",
95-
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.4.6/rules_nodejs-4.4.6.tar.gz"],
96-
)
97-
98-
load(
99-
"@build_bazel_rules_nodejs//:index.bzl",
100-
"node_repositories",
101-
"yarn_install",
102-
)
103-
104-
### https://bazelbuild.github.io/rules_nodejs/Built-ins.html#usage
105-
node_repositories(
106-
node_version = "16.13.0",
107-
package_json = ["//web:package.json"],
108-
yarn_version = "1.22.4",
109-
)
110-
111-
yarn_install(
112-
name = "npm",
113-
frozen_lockfile = False,
114-
package_json = "//web:package.json",
115-
yarn_lock = "//web:yarn.lock",
116-
)
117-
118-
load("@npm//@bazel/labs:package.bzl", "npm_bazel_labs_dependencies")
119-
120-
npm_bazel_labs_dependencies()
121-
12289
# gazelle:repository_macro repositories.bzl%go_repositories

cmd/pipecd/BUILD.bazel

-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ go_library(
6464

6565
go_binary(
6666
name = "pipecd",
67-
data = [
68-
"//web:static",
69-
],
7067
embed = [":go_default_library"],
7168
visibility = ["//visibility:public"],
7269
)

web/BUILD.bazel

-126
This file was deleted.

web/jest.config.local.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
"<rootDir>/file-transformer.js",
77
},
88
moduleNameMapper: {
9-
"^pipecd/(.*)$": "<rootDir>/../bazel-bin/$1",
9+
"^pipecd/(.*)$": "<rootDir>/../$1",
1010
"^~/(.*)$": "<rootDir>/src/$1",
1111
"^~~/(.*)$": "<rootDir>/$1",
1212
},

web/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"private": true,
66
"license": "Apache-2.0",
77
"scripts": {
8+
"build": "webpack build --mode production --env htmlTemplate=./base.html --config ./webpack.config.js",
89
"dev": "STABLE_VERSION=`git describe --tags --always --dirty --abbrev=7` webpack serve --env htmlTemplate=./base.html --config ./webpack.config.dev.js",
910
"gen": "scaffdog generate",
1011
"test": "TZ=Asia/Tokyo jest --config jest.config.local.js",

0 commit comments

Comments
 (0)