Skip to content

Commit

Permalink
Deyarn (#916)
Browse files Browse the repository at this point in the history
* WIP

* Rm modd as a dependency

* Cache action

* Install chromium at IT time

* IT

* One last try

* Try sudo

* Just Test in the action

* Try just UI

* Split out API/CLI tests

* Try different port

* rm finish flag

* Update cache action

* Go cache

* Back to basics

* Fix port

* Try to remove playwright deps

* Install playwright at runtime

* back to IT image
  • Loading branch information
markphelps committed Jun 30, 2022
1 parent 7fa2bea commit 26a2714
Show file tree
Hide file tree
Showing 21 changed files with 38,648 additions and 11,072 deletions.
1 change: 0 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"golang.Go",
"gamunu.vscode-yarn",
"dbaeumer.vscode-eslint",
"octref.vetur",
"zxh404.vscode-proto3",
Expand Down
22 changes: 7 additions & 15 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,16 @@ jobs:
with:
go-version: "1.17.x"

- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- uses: actions/checkout@v3

- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}

- name: Go Mod Cache
uses: actions/cache@v3
- uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Benchmark (SQLite)
run: go test -bench=. ./... -run=XXX -v
Expand Down
18 changes: 6 additions & 12 deletions .github/workflows/database-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,14 @@ jobs:
with:
go-version: "1.17.x"

- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}

- uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Unit Test (Postgres)
run: DB_URL="postgres://postgres:password@localhost:${{ job.services.postgres.ports['5432'] }}/flipt_test?sslmode=disable" go test -count=1 -v ./...
Expand Down
34 changes: 8 additions & 26 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,19 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: "18"
cache: "npm"
cache-dependency-path: ui/package-lock.json

- uses: arduino/setup-task@v1

- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- uses: actions/checkout@v3

- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}

- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build the binary
run: |
Expand Down
22 changes: 7 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,14 @@ jobs:
with:
go-version: ${{ matrix.go }}

- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}

- name: Go Mod Cache
uses: actions/cache@v3
- uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Unit Test (SQLite)
run: go test -covermode=count -coverprofile=coverage.txt -count=1 ./...
Expand Down
9 changes: 3 additions & 6 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Before starting, make sure you have the following installed:
- [SQLite](https://sqlite.org/index.html)
- [Go 1.17+](https://golang.org/doc/install)
- [NodeJS >= 18](https://nodejs.org/en/)
- [Yarn](https://yarnpkg.com/en/)
- [Task](https://taskfile.dev/#/)

## Setup
Expand Down Expand Up @@ -56,7 +55,7 @@ Running `task assets` will regenerate the embedded assets (ui, api documentation

#### UI components

The UI is built using [Yarn](https://yarnpkg.com/en/) and [webpack](https://webpack.js.org/) and is also statically compiled into the Flipt binary.
The UI is built using [NPM](https://nodejs.org/en/) and [webpack](https://webpack.js.org/) and is also statically compiled into the Flipt binary.

The [ui/README.md](https://github.com/markphelps/flipt/tree/main/ui/README.md) has more information on how to build the UI and also how to run it locally during development.

Expand All @@ -74,14 +73,12 @@ If you have access to [GitHub Codespaces](https://github.com/features/codespaces

### Building/Running

Flipt uses [modd](https://github.com/cortesi/modd) for managing processes during development.

Run `task dev` from the project root. See [modd.conf](modd.conf) for configuration.
Run `script/server` from the project root.

The `webpack-dev-server` that is used when running the UI in development mode will rebuild the UI assets when applicable files in the `ui` folder change. See [ui/README.md](https://github.com/markphelps/flipt/tree/main/ui/README.md) for more info.

### Ports

The three ports `8080`, `8081`, `9000` will be forwarded to your local machine automatically.

`8081` is the UI dev port that runs the `yarn dev server` that you can open in your browser.
`8081` is the UI dev port that runs the `npm dev server` that you can open in your browser.
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@ RUN apt-get update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# install yarn & nodejs
RUN curl -sSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

# install nodejs
RUN curl -sSL https://deb.nodesource.com/setup_18.x | bash && \
apt-get update && \
apt-get install -y --no-install-recommends \
nodejs \
yarn && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

Expand Down
5 changes: 1 addition & 4 deletions Dockerfile.it
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:21.10
FROM ubuntu:focal

LABEL org.opencontainers.image.source="https://github.com/markphelps/flipt"

Expand All @@ -16,8 +16,6 @@ RUN curl -sL https://deb.nodesource.com/setup_18.x | bash
RUN apt-get update && \
apt-get install -y nodejs

RUN npm install -g yarn

# specify location of to be installed browsers
# so that our IT can find them at runtime
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
Expand All @@ -27,7 +25,6 @@ RUN mkdir ${PLAYWRIGHT_BROWSERS_PATH}
# need to install browser and deps for playwright
# using this hack because of npm junk: https://github.com/microsoft/playwright/issues/9858#issuecomment-954311179
RUN mkdir /tmp/pwt && cd /tmp/pwt && \
npm install @playwright/test && \
npx playwright install chromium --with-deps && \
chmod -R 777 /ms-playwright

Expand Down
16 changes: 9 additions & 7 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tasks:
desc: Build the UI
deps: [assets:deps]
cmds:
- cd ui && yarn build
- cd ui && npm run build
env:
NODE_OPTIONS: --openssl-legacy-provider
sources:
Expand All @@ -35,10 +35,15 @@ tasks:
assets:deps:
desc: Install UI dependencies
cmds:
- cd ui && yarn --frozen-lockfile
- cd ui && npm ci
env:
NODE_OPTIONS: --openssl-legacy-provider

assets:dev:
desc: Run the UI dev server
cmds:
- cd ui && npm run dev

bench:
desc: Run benchmarks
cmds:
Expand Down Expand Up @@ -103,12 +108,9 @@ tasks:
COVERAGE_FILE: coverage.txt

dev:
desc: Start the server and UI in development modes
desc: Start the server
cmds:
- modd
preconditions:
- sh: "! [ -x '$(command -v modd)' ]"
msg: "modd not found. run bootstrap."
- go run ./cmd/flipt/. --config ./config/local.yml --force-migrate

fmt:
desc: Run goimports
Expand Down
11 changes: 0 additions & 11 deletions _tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.17

require (
github.com/bufbuild/buf v1.4.0
github.com/cortesi/modd v0.0.0-20211215124449-6083f9d1c171
github.com/golangci/golangci-lint v1.43.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.3
golang.org/x/tools v0.1.11
Expand All @@ -20,23 +19,18 @@ require (
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/OpenPeeDeeP/depguard v1.0.1 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15 // indirect
github.com/alexkohler/prealloc v1.0.0 // indirect
github.com/ashanbrown/forbidigo v1.2.0 // indirect
github.com/ashanbrown/makezero v0.0.0-20210520155254-b6261585ddde // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bkielbasa/cyclop v1.2.0 // indirect
github.com/blizzy78/varnamelen v0.3.0 // indirect
github.com/bmatcuk/doublestar v1.3.4 // indirect
github.com/bombsimon/wsl/v3 v3.3.0 // indirect
github.com/breml/bidichk v0.1.1 // indirect
github.com/butuzov/ireturn v0.1.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/charithe/durationcheck v0.0.9 // indirect
github.com/chavacava/garif v0.0.0-20210405164556-e8a0a408d6af // indirect
github.com/cortesi/moddwatch v0.0.0-20210222043437-a6aaad86a36e // indirect
github.com/cortesi/termlog v0.0.0-20210222042314-a1eec763abec // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/daixiang0/gci v0.2.9 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down Expand Up @@ -128,7 +122,6 @@ require (
github.com/prometheus/procfs v0.6.0 // indirect
github.com/quasilyte/go-ruleguard v0.3.13 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect
github.com/rjeczalik/notify v0.0.0-20181126183243-629144ba06a1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/ryancurrah/gomodguard v1.2.3 // indirect
github.com/ryanrolds/sqlclosecheck v0.3.0 // indirect
Expand Down Expand Up @@ -163,23 +156,19 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
google.golang.org/grpc v1.46.2 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
gopkg.in/ini.v1 v1.63.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/tools v0.2.1 // indirect
mvdan.cc/gofumpt v0.1.1 // indirect
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed // indirect
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect
mvdan.cc/sh/v3 v3.3.0-0.dev.0.20210224101809-fb5052e7a010 // indirect
mvdan.cc/unparam v0.0.0-20210104141923-aac4ce9116a7 // indirect
)
Loading

0 comments on commit 26a2714

Please sign in to comment.