mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
chore: add script to install yarn dependencies
* Use frozen lockfile in build for reproducible builds * Do not install optional dependencies * Suppress interactive prompts in build
This commit is contained in:
22
.github/workflows/coder.yaml
vendored
22
.github/workflows/coder.yaml
vendored
@ -60,8 +60,7 @@ jobs:
|
|||||||
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
|
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
|
||||||
- name: Install node_modules
|
- name: Install node_modules
|
||||||
run: yarn install
|
run: ./scripts/yarn_install.sh
|
||||||
working-directory: site
|
|
||||||
|
|
||||||
- name: "yarn lint"
|
- name: "yarn lint"
|
||||||
run: yarn lint
|
run: yarn lint
|
||||||
@ -108,8 +107,7 @@ jobs:
|
|||||||
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
|
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
|
||||||
- name: Install node_modules
|
- name: Install node_modules
|
||||||
run: yarn install
|
run: ./scripts/yarn_install.sh
|
||||||
working-directory: site
|
|
||||||
|
|
||||||
- name: "make fmt"
|
- name: "make fmt"
|
||||||
run: "make --output-sync -j fmt"
|
run: "make --output-sync -j fmt"
|
||||||
@ -214,8 +212,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: "14"
|
node-version: "14"
|
||||||
|
|
||||||
- run: yarn install
|
- name: Install node_modules
|
||||||
working-directory: site
|
run: ./scripts/yarn_install.sh
|
||||||
|
|
||||||
- uses: actions/setup-go@v2
|
- uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
@ -252,13 +250,15 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: "14"
|
node-version: "14"
|
||||||
|
|
||||||
- run: yarn install
|
- name: Install node_modules
|
||||||
|
run: ./scripts/yarn_install.sh
|
||||||
|
|
||||||
|
- name: Build frontend
|
||||||
|
run: yarn build
|
||||||
working-directory: site
|
working-directory: site
|
||||||
|
|
||||||
- run: yarn build
|
- name: Build Storybook
|
||||||
working-directory: site
|
run: yarn storybook:build
|
||||||
|
|
||||||
- run: yarn storybook:build
|
|
||||||
working-directory: site
|
working-directory: site
|
||||||
|
|
||||||
- run: yarn test:coverage
|
- run: yarn test:coverage
|
||||||
|
@ -22,7 +22,7 @@ function create_initial_user() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Run yarn install, to make sure node_modules are ready to go
|
# Run yarn install, to make sure node_modules are ready to go
|
||||||
yarn --cwd=./site install
|
"$PROJECT_ROOT/scripts/yarn_install.sh"
|
||||||
|
|
||||||
# Do initial build - a dev build for coderd.
|
# Do initial build - a dev build for coderd.
|
||||||
# It's OK that we don't build the front-end before - because the front-end
|
# It's OK that we don't build the front-end before - because the front-end
|
||||||
|
42
scripts/yarn_install.sh
Executable file
42
scripts/yarn_install.sh
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Run "yarn install" with flags appropriate to the environment
|
||||||
|
# (local development vs build system)
|
||||||
|
#
|
||||||
|
# Usage: yarn_install.sh [optional extra flags]
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
PROJECT_ROOT=$(git rev-parse --show-toplevel)
|
||||||
|
cd "$PROJECT_ROOT/site"
|
||||||
|
|
||||||
|
yarn_flags=(
|
||||||
|
# Do not execute install scripts
|
||||||
|
# TODO: check if build works properly with this enabled
|
||||||
|
# --ignore-scripts
|
||||||
|
|
||||||
|
# Check if existing node_modules are valid
|
||||||
|
# TODO: determine if this is necessary
|
||||||
|
# --check-files
|
||||||
|
|
||||||
|
# Do not install optional dependencies
|
||||||
|
--ignore-optional
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ -n "${CI:-}" ]; then
|
||||||
|
yarn_flags+=(
|
||||||
|
# Install dependencies from lockfile, ensuring builds are fully
|
||||||
|
# reproducible
|
||||||
|
--frozen-lockfile
|
||||||
|
# Suppress progress information
|
||||||
|
--silent
|
||||||
|
# Disable interactive prompts for build
|
||||||
|
--non-interactive
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Append whatever is specified on the command line
|
||||||
|
yarn_flags+=("$@")
|
||||||
|
|
||||||
|
echo "+ yarn install ${yarn_flags[*]}"
|
||||||
|
yarn install "${yarn_flags[@]}"
|
Reference in New Issue
Block a user