Skip to content

Commit

Permalink
Rename ui-cra -> ui and move package.json to root (#3263)
Browse files Browse the repository at this point in the history
* Search replace all the ui-cra to ui
* and move package.json to root
* run eject
  • Loading branch information
foot authored Sep 5, 2023
1 parent f36d549 commit 3cfd1ec
Show file tree
Hide file tree
Showing 371 changed files with 2,088 additions and 276 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.git
ui-cra/node_modules
ui/node_modules
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/ui-cra/src/components/Pipelines @jpellizzari
/ui-cra/src/components/ProgressiveDelivery @jpellizzari
/ui/src/components/Pipelines @jpellizzari
/ui/src/components/ProgressiveDelivery @jpellizzari
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
updates:
# Maintain dependencies for frontend
- package-ecosystem: "npm"
directory: "/ui-cra"
directory: "/"
schedule:
interval: "daily"
reviewers:
Expand Down
85 changes: 43 additions & 42 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
required: true
type: string
gitops_platforms:
description: "Platforms for gitops compilation - JSON string e.g '[\"ubuntu-latest\", \"macOS-latest\"]'"
description: Platforms for gitops compilation - JSON string e.g '["ubuntu-latest", "macOS-latest"]'
required: false
default: '["ubuntu-latest"]'
type: string
Expand All @@ -20,7 +20,8 @@ on:
WGE_S3_AWS_SECRET_ACCESS_KEY: { required: true }
WGE_HELM_REPO_USERNAME: { required: false }
WGE_HELM_REPO_PASSWORD: { required: false }
WEAVE_GITOPS_CLUSTERS_GITHUB_WORKLOAD_IDENTITY_PROVIDER: { required: false }
WEAVE_GITOPS_CLUSTERS_GITHUB_WORKLOAD_IDENTITY_PROVIDER:
{ required: false }
WEAVE_GITOPS_CLUSTERS_GITHUB_SERVICE_ACCOUNT: { required: false }

env:
Expand Down Expand Up @@ -95,7 +96,7 @@ jobs:
TIMESTAMP=$(date +%s)
TAG=$(git describe --always --match "v*" --abbrev=0)
HELM_TAG=${TAG}-${TIMESTAMP}-g${SHORT_HASH}
# Publish the MCCP Helm v3 chart to branch helm repo
BRANCH_NAME=${GITHUB_REF##*/}
BRANCH_HELM_REPO="dev/branches/${BRANCH_NAME}"
Expand Down Expand Up @@ -181,7 +182,7 @@ jobs:
git fetch --tags -f
- name: build
run: |
make DOCKER_BUILDKIT=1 GITHUB_BUILD_TOKEN=${GITHUB_BUILD_TOKEN} ui-cra/.uptodate
make DOCKER_BUILDKIT=1 GITHUB_BUILD_TOKEN=${GITHUB_BUILD_TOKEN} ui/.uptodate
- name: Login to Docker Hub
uses: docker/[email protected]
with:
Expand All @@ -198,41 +199,41 @@ jobs:
matrix:
os: ${{ fromJSON(inputs.gitops_platforms) }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x
- name: Configure git for private modules
run: |
git config --global url."https://${GITHUB_BUILD_USERNAME}:${GITHUB_BUILD_TOKEN}@github.com".insteadOf "https://github.com"
- name: Install dependencies
run: |
go mod download
- name: Clean
run: make clean
- id: gitsha
run: |
gitsha=$(git rev-parse --short ${{ github.sha }})
echo "sha=$gitsha" >> $GITHUB_OUTPUT
- name: build
run: |
make cmd/gitops/gitops
mv cmd/gitops/gitops cmd/gitops/gitops-${{matrix.os}}
- uses: actions/[email protected]
with:
name: gitops
path: cmd/gitops/gitops-${{matrix.os}}
retention-days: 1
- name: Configure AWS Credentials
if: ${{ (github.ref_name == 'main') && (github.event_name == 'schedule') }}
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.WGE_S3_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.WGE_S3_AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- name: Publish gitops binary to s3
if: ${{ (github.ref_name == 'main') && (github.event_name == 'schedule') }}
run: |
aws s3 cp cmd/gitops/gitops-${{matrix.os}} s3://weaveworks-wkp/gitops/gitops-${{matrix.os}}-${{steps.gitsha.outputs.sha}}
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x
- name: Configure git for private modules
run: |
git config --global url."https://${GITHUB_BUILD_USERNAME}:${GITHUB_BUILD_TOKEN}@github.com".insteadOf "https://github.com"
- name: Install dependencies
run: |
go mod download
- name: Clean
run: make clean
- id: gitsha
run: |
gitsha=$(git rev-parse --short ${{ github.sha }})
echo "sha=$gitsha" >> $GITHUB_OUTPUT
- name: build
run: |
make cmd/gitops/gitops
mv cmd/gitops/gitops cmd/gitops/gitops-${{matrix.os}}
- uses: actions/[email protected]
with:
name: gitops
path: cmd/gitops/gitops-${{matrix.os}}
retention-days: 1
- name: Configure AWS Credentials
if: ${{ (github.ref_name == 'main') && (github.event_name == 'schedule') }}
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.WGE_S3_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.WGE_S3_AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- name: Publish gitops binary to s3
if: ${{ (github.ref_name == 'main') && (github.event_name == 'schedule') }}
run: |
aws s3 cp cmd/gitops/gitops-${{matrix.os}} s3://weaveworks-wkp/gitops/gitops-${{matrix.os}}-${{steps.gitsha.outputs.sha}}
12 changes: 5 additions & 7 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ jobs:
export GOPRIVATE=github.com/weaveworks
go get -u github.com/weaveworks/weave-gitops@$latest_tag
go mod tidy
cd ui-cra
yarn add @weaveworks/weave-gitops@$latest_tag
# This is a convience to help auto-update snapshots if core components have changed.
# However it can still fail if larger changes have been made, breaking the PR creation.
Expand Down Expand Up @@ -77,7 +76,7 @@ jobs:
- name: Check out enterprise
uses: actions/checkout@v3
with:
repository: 'weaveworks/weave-gitops-enterprise'
repository: "weaveworks/weave-gitops-enterprise"
token: ${{ secrets.GITHUB_TOKEN }}
ref: main
fetch-depth: 0
Expand All @@ -103,7 +102,6 @@ jobs:
echo $remote_main
go get -u github.com/weaveworks/weave-gitops@$remote_main
go mod tidy
cd ui-cra
npm_version=$(yarn info @weaveworks/weave-gitops-main time --json | jq -r '.data | keys | .[] | select(contains("$(remote_main)"))')
yarn add @weaveworks/weave-gitops@npm:@weaveworks/weave-gitops-main@$npm_version
# This is a convience to help auto-update snapshots if core components have changed.
Expand All @@ -125,10 +123,10 @@ jobs:
title: "Bump weave-gitops to latest"
body: |
Update weave-gitops to unstable commit ${{ needs.ci-publish-js-lib.outputs.js-version }}
# Uncomment this when you want to involve the author:
#
# cc @${{ github.event.sender.login }}
# Uncomment this when you want to involve the author:
#
# cc @${{ github.event.sender.login }}
commit-message: "Bump version of weave-gitops to latest"
token: ${{ secrets.BUILD_BOT_PERSONAL_ACCESS_TOKEN }}
delete-branch: true
labels: "exclude from release notes"
labels: "exclude from release notes"
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ jobs:
restore-keys: |
${{ runner.os }}-${{ env.YARN_CACHE_NAME }}-
- name: Install modules
run: cd ui-cra && yarn --pure-lockfile
run: yarn --pure-lockfile
- name: Run Front-end Unit Tests
run: cd ui-cra && ./node_modules/.bin/react-scripts test
run: yarn test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,8 @@ tools/core-files
yarn-error.log
__pycache__

# ui production build
/build

*.db
*.bolt
File renamed without changes.
6 changes: 1 addition & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ can be annoying. To spin up a local development frontend against your
development cluster, run:

```
cd ui-cra
yarn
PROXY_HOST=http://localhost:8000 yarn start
```
Expand Down Expand Up @@ -475,7 +474,6 @@ We usually develop the UI against the test server and by default the UI dev
server will use that.
```bash
cd ui-cra
yarn
yarn start
```
Expand All @@ -487,7 +485,6 @@ Open up http://localhost:3000. Changes to code will be hot-reloaded.
To start the `jest` test runner CLI dialog:
```
$ cd ui-cra
$ yarn test
PASS src/components/Applications/__tests__/index.test.tsx
Expand Down Expand Up @@ -573,7 +570,6 @@ For another method that has fewer caveats, look at "How to update
One magical command to "reload" core (assumes the project directories are located in the same directory):
```bash
# In the weave-gitops-enterprise repo, navigate to ./ui-cra.
# Note, this assumes you have core and EE at the same level in the file system
make core-ui && make core-lib
```
Expand All @@ -590,7 +586,7 @@ go get -d github.com/weaveworks/weave-gitops@$WG_VERSION
go mod tidy
# 2. Update the frontend typescript/javascript code
cd ui-cra && yarn add @weaveworks/weave-gitops@$WG_VERSION
yarn add @weaveworks/weave-gitops@$WG_VERSION
```
## How to update `weave-gitops` to a non-released version during development
Expand Down
48 changes: 34 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ cmd/gitops/gitops: cmd/gitops/main.go $(shell find cmd/gitops -name "*.go")
CGO_ENABLED=0 go build -ldflags "$(shell make echo-ldflags)" -gcflags='all=-N -l' -o $@ $(GO_BUILD_OPTS) $<

UI_SERVER := docker.io/weaveworks/weave-gitops-enterprise-ui-server
ui-cra/.uptodate: ui-cra/*
ui/.uptodate: ui/*
$(SUDO) docker build \
--build-arg=version=$(WEAVE_GITOPS_VERSION) \
--build-arg=revision=$(GIT_REVISION) \
--build-arg=GITHUB_TOKEN=$(GITHUB_BUILD_TOKEN) \
--build-arg=REACT_APP_DISABLE_PROGRESSIVE_DELIVERY=$(REACT_APP_DISABLE_PROGRESSIVE_DELIVERY) \
--build-arg=now=$(TIME_NOW) \
--tag $(UI_SERVER) \
$(@D)/
--file ui/Dockerfile \
.
$(SUDO) docker tag $(UI_SERVER) $(UI_SERVER):$(IMAGE_TAG)
touch $@

Expand Down Expand Up @@ -131,14 +132,6 @@ godeps=$(shell go list -deps -f '{{if not .Standard}}{{$$dep := .}}{{range .GoFi
dependencies: ## Install build dependencies
$(CURRENT_DIR)/tools/download-deps.sh $(CURRENT_DIR)/tools/dependencies.toml

.PHONY: ui-cra/build
ui-cra/build:
make build VERSION=$(VERSION) -C ui-cra

ui-audit:
# Check js packages for any high or critical vulnerabilities
cd ui-cra && yarn audit --level high; if [ $$? -gt 7 ]; then echo "Failed yarn audit"; exit 1; fi

lint:
bin/go-lint
@go install github.com/yoheimuta/protolint/cmd/protolint@latest
Expand All @@ -152,8 +145,8 @@ update-weave-gitops:
$(eval SHORTHASH := $(shell curl -q 'https://api.github.com/repos/weaveworks/weave-gitops/branches/$(BRANCH)' | jq -r '.commit.sha[:8]'))
go get -d github.com/weaveworks/weave-gitops@$(SHORTHASH)
go mod tidy
$(eval NPM_VERSION := $(shell cd ui-cra && yarn info @weaveworks/weave-gitops-main time --json | jq -r '.data | keys | .[] | select(contains("$(SHORTHASH)"))'))
cd ui-cra && yarn add @weaveworks/weave-gitops@npm:@weaveworks/weave-gitops-main@$(NPM_VERSION)
$(eval NPM_VERSION := $(shell yarn info @weaveworks/weave-gitops-main time --json | jq -r '.data | keys | .[] | select(contains("$(SHORTHASH)"))'))
yarn add @weaveworks/weave-gitops@npm:@weaveworks/weave-gitops-main@$(NPM_VERSION)

# We select which directory we want to descend into to not execute integration
# tests here.
Expand All @@ -170,7 +163,7 @@ unit-tests: $(GENERATED)

ui-build-for-tests:
# Github actions npm is slow sometimes, hence increasing the network-timeout
yarn config set network-timeout 300000 && cd ui-cra && yarn install && yarn build
yarn config set network-timeout 300000 && yarn install && yarn build

integration-tests:
$(CURRENT_DIR)/tools/download-deps.sh $(CURRENT_DIR)/tools/test-dependencies.toml
Expand All @@ -184,7 +177,7 @@ clean:
rm -rf $(UPTODATE_FILES)
rm -f $(BINARIES)
rm -f $(GENERATED)
rm -rf ui-cra/build
rm -rf build

push:
for IMAGE_NAME in $(IMAGE_NAMES); do \
Expand All @@ -199,6 +192,33 @@ proto: ## Generate protobuf files
fakes: ## Generate testing fakes
go generate ./...

# --- UI

CALENDAR_VERSION=$(shell date +"%Y-%m")

.PHONY: node_modules
node_modules: package.json yarn.lock
yarn config set network-timeout 300000 && yarn install --prod --frozen-lockfile

ui-build: node_modules $(shell find ui/src -type f)
REACT_APP_DISABLE_PROGRESSIVE_DELIVERY="$(REACT_APP_DISABLE_PROGRESSIVE_DELIVERY)" REACT_APP_VERSION="$(CALENDAR_VERSION) $(VERSION)" yarn build

# This job assumes that the weave-gitops repo located next to this repo in the filesystem
core-ui:
cd ../../weave-gitops && \
npm run build:lib && \
npm run typedefs && \
cd ../weave-gitops-enterprise

core-lib:
rm -rf node_modules/@weaveworks/weave-gitops/
rm -rf .parcel-cache/
yarn add ../../weave-gitops/dist

ui-audit:
# Check js packages for any high or critical vulnerabilities
yarn audit --level high; if [ $$? -gt 7 ]; then echo "Failed yarn audit"; exit 1; fi

# Run make swagger-docs and go to http://localhost:6001 to view the Swagger docs
# NOTE: Requires a running Docker Server

Expand Down
14 changes: 7 additions & 7 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,16 @@ elif native_build:

local_resource(
'ui-native-build',
'make build',
'make ui-build',
deps=[
'./ui-cra/src',
'./ui/src',
],
dir='ui-cra',
labels=['local'],
)
docker_build(
'weaveworks/weave-gitops-enterprise-ui-server',
'ui-cra',
dockerfile="ui-cra/dev.dockerfile",
'.',
dockerfile="ui/dev.dockerfile",
build_args={'GITHUB_TOKEN': os.getenv('GITHUB_TOKEN')},
)

Expand All @@ -122,7 +121,8 @@ else:

docker_build(
'weaveworks/weave-gitops-enterprise-ui-server',
'ui-cra',
'.',
dockerfile='ui/Dockerfile',
build_args={'GITHUB_TOKEN': os.getenv('GITHUB_TOKEN')},
)

Expand Down Expand Up @@ -165,7 +165,7 @@ else:
docker_build(
'weaveworks/weave-gitops-enterprise-clusters-service',
'.',
ignore=["ui-cra"],
ignore=["ui"],
dockerfile='cmd/clusters-service/Dockerfile',
build_args={'GITHUB_BUILD_TOKEN': os.getenv('GITHUB_TOKEN'),'image_tag': 'tilt'},
entrypoint= ["/clusters-service", "--log-level=debug"]
Expand Down
2 changes: 1 addition & 1 deletion buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ plugins:
opt:
- allow_delete_body=true
- name: grpc-gateway-ts
out: ./ui-cra/src
out: ./ui/src
opt: []
strategy: all
2 changes: 1 addition & 1 deletion cmd/clusters-service/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ plugins:
out: api
opt: allow_delete_body=true
- name: grpc-gateway-ts
out: ../../ui-cra/src/cluster-services
out: ../../ui/src/cluster-services
Loading

0 comments on commit 3cfd1ec

Please sign in to comment.