Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build scripts #2302

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ target/
query-node/generated
query-node/**/dist
query-node/lib
cli/
tests/
3 changes: 3 additions & 0 deletions .github/workflows/content-directory-schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ jobs:
- name: validate
run: |
yarn install --frozen-lockfile
yarn workspace @joystream/types build
yarn workspace @joystream/cd-schemas generate:all
yarn workspace @joystream/cd-schemas build
yarn workspace @joystream/cd-schemas checks --quiet
6 changes: 6 additions & 0 deletions .github/workflows/joystream-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
- name: checks
run: |
yarn install --frozen-lockfile
yarn workspace @joystream/types build
yarn workspace @joystream/cd-schemas generate:all
yarn workspace @joystream/cd-schemas build
yarn workspace @joystream/cli checks --quiet
- name: yarn pack test
run: |
Expand All @@ -39,6 +42,9 @@ jobs:
- name: checks
run: |
yarn install --frozen-lockfile --network-timeout 120000
yarn workspace @joystream/types build
yarn workspace @joystream/cd-schemas generate:all
yarn workspace @joystream/cd-schemas build
yarn workspace @joystream/cli checks --quiet
- name: yarn pack test
run: |
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/joystream-types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- name: checks
run: |
yarn install --frozen-lockfile
yarn workspace @joystream/types build
yarn workspace @joystream/types checks --quiet
- name: npm pack test
run: |
Expand All @@ -40,6 +41,9 @@ jobs:
- name: checks
run: |
yarn install --frozen-lockfile --network-timeout 120000
yarn workspace @joystream/types build
yarn workspace @joystream/cd-schemas generate:all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to build cd-schemas here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in d9d6762

yarn workspace @joystream/cd-schemas build
yarn workspace @joystream/types checks --quiet
- name: npm pack test
run: |
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/network-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ jobs:
- name: checks
run: |
yarn install --frozen-lockfile
yarn workspace @joystream/types build
yarn workspace @joystream/cd-schemas generate:all
yarn workspace @joystream/cd-schemas build
yarn workspace @joystream/cli build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for building the CLI here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, will drop

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in d9d6762

yarn workspace network-tests checks --quiet

network_build_osx:
Expand All @@ -34,4 +38,8 @@ jobs:
- name: checks
run: |
yarn install --frozen-lockfile --network-timeout 120000
yarn workspace @joystream/types build
yarn workspace @joystream/cd-schemas generate:all
yarn workspace @joystream/cd-schemas build
yarn workspace @joystream/cli build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for building the CLI here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no will drop

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in d9d6762

yarn workspace network-tests checks --quiet
4 changes: 4 additions & 0 deletions .github/workflows/pioneer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- name: build
run: |
yarn install --frozen-lockfile
yarn workspace @joystream/types build
yarn workspace pioneer build

pioneer_build_osx:
Expand All @@ -34,6 +35,7 @@ jobs:
- name: build
run: |
yarn install --frozen-lockfile --network-timeout 120000
yarn workspace @joystream/types build
yarn workspace pioneer build

pioneer_lint_ubuntu:
Expand All @@ -51,6 +53,7 @@ jobs:
- name: lint
run: |
yarn install --frozen-lockfile
yarn workspace @joystream/types build
yarn workspace pioneer lint --quiet

pioneer_lint_osx:
Expand All @@ -68,4 +71,5 @@ jobs:
- name: lint
run: |
yarn install --frozen-lockfile --network-timeout 120000
yarn workspace @joystream/types build
yarn workspace pioneer lint --quiet
28 changes: 21 additions & 7 deletions .github/workflows/run-network-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ jobs:
docker load --input joystream-node-docker-image.tar.gz
docker images
- name: Install packages and dependencies
run: yarn install --frozen-lockfile
run: |
yarn install --frozen-lockfile
yarn build:packages
- name: Ensure tests are runnable
run: yarn workspace network-tests build
- name: Execute network tests
Expand All @@ -121,7 +123,9 @@ jobs:
docker load --input joystream-node-docker-image.tar.gz
docker images
- name: Install packages and dependencies
run: yarn install --frozen-lockfile
run: |
yarn install --frozen-lockfile
yarn build:packages
- name: Ensure tests are runnable
run: yarn workspace network-tests build
- name: Execute network tests
Expand All @@ -145,7 +149,11 @@ jobs:
docker load --input joystream-node-docker-image.tar.gz
docker images
- name: Install packages and dependencies
run: yarn install --frozen-lockfile
run: |
yarn install --frozen-lockfile
yarn workspace @joystream/types build
yarn workspace @joystream/cd-schemas generate:all
yarn workspace @joystream/cd-schemas build
- name: Ensure tests are runnable
run: yarn workspace @joystream/cd-schemas checks --quiet
- name: Start chain
Expand All @@ -171,9 +179,13 @@ jobs:
docker load --input joystream-node-docker-image.tar.gz
docker images
- name: Install packages and dependencies
run: yarn install --frozen-lockfile
- name: Ensure query-node builds
run: yarn workspace query-node-root build
run: |
yarn install --frozen-lockfile
yarn workspace @joystream/types build
yarn workspace @joystream/cd-schemas generate:all
yarn workspace @joystream/cd-schemas build
yarn workspace query-node-root build
yarn workspace @joystream/cli build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for building the CLI here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think query-node tests currently use the cli so will remove

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in d9d6762

- name: Ensure tests are runnable
run: yarn workspace network-tests build
# Bring up hydra query-node development instance, then run content directory
Expand All @@ -199,7 +211,9 @@ jobs:
docker load --input joystream-node-docker-image.tar.gz
docker images
- name: Install packages and dependencies
run: yarn install --frozen-lockfile
run: |
yarn install --frozen-lockfile
yarn workspace @joystream/types build
- name: Build storage node
run: yarn workspace storage-node build
- name: Start Services
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/storage-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
- name: checks
run: |
yarn install --frozen-lockfile
yarn workspace @joystream/types build
yarn workspace storage-node checks --quiet
yarn workspace storage-node build

storage_node_build_osx:
name: MacOS Checks
Expand All @@ -34,4 +36,6 @@ jobs:
- name: checks
run: |
yarn install --frozen-lockfile --network-timeout 120000
yarn workspace @joystream/types build
yarn workspace storage-node checks --quiet
yarn workspace storage-node build
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ After cloning the repo run the following initialization scripts:
# Install rust toolchain
./setup.sh

# Install npm package dependencies
# Also good habit to run this when switching between branches
yarn install
# Install npm package dependencies, build packages and docker images
yarn build

# run some tests
yarn cargo-checks
# start a local development network
yarn start
```

## Software
Expand Down Expand Up @@ -75,6 +74,7 @@ The HEAD of the master branch should always be used for the correct version of t
```sh
git checkout master
yarn install
yarn build:packages
yarn workspace pioneer start
```

Expand All @@ -89,7 +89,7 @@ You can also run your our own joystream-node:

```sh
git checkout master
WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo build --release
WASM_BUILD_TOOLCHAIN=nightly-2021-02-20 cargo build --release
./target/release/joystream-node -- --pruning archive --chain testnets/joy-testnet-4.json
```

Expand Down
24 changes: 21 additions & 3 deletions apps.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,31 @@ FROM node:12 as builder

WORKDIR /joystream
COPY . /joystream
RUN rm -fr /joystream/pioneer

# Do not set NODE_ENV=production until after running yarn install
# to ensure dev dependencies are installed.
RUN yarn install --frozen-lockfile
RUN yarn --forzen-lockfile

RUN yarn workspace pioneer build
RUN yarn workspace storage-node build
RUN yarn workspace @joystream/types build
RUN yarn workspace query-node-root build
RUN yarn workspace storage-node build

# Second stage to reduce image size, enable it when
# all packages have correctly identified what is a devDependency and what is not.
# It will reduce the image size by about 500MB (down from 2.2GB to 1.7GB)

# # Remove files that are not needed after build.
# # We will re-fetch only dependencies needed for running the apps.
# RUN rm -fr node_modules/
# RUN rm -fr .git/

# FROM node:12
# WORKDIR /joystream
# COPY --from=builder /joystream/ /joystream/

# # Skip installing devDependencies, since we have already built the packages.
# ENV NODE_ENV=production
# RUN yarn install --forzen-lockfile --production

ENTRYPOINT [ "yarn" ]
37 changes: 37 additions & 0 deletions build-docker-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

set -e

if ! command -v docker-compose &> /dev/null
then
echo "docker-compose not found. Skipping docker image builds."
exit 0
fi

# Build or fetch cached joystream/node docker image
if [[ "$SKIP_JOYSTREAM_NODE" = 1 || "$SKIP_JOYSTREAM_NODE" = "true" ]]; then
echo "Skipping build of joystream/node docker image."
else
# Fetch a cached joystream/node image if one is found matching code shasum instead of building
CODE_HASH=`scripts/runtime-code-shasum.sh`
IMAGE=joystream/node:${CODE_HASH}
echo "Trying to fetch cached ${IMAGE} image"
docker pull ${IMAGE} || :

if ! docker inspect ${IMAGE} > /dev/null;
then
echo "Fetch failed, building image locally"
docker-compose build joystream-node
else
echo "Tagging cached image as 'latest'"
docker image tag ${IMAGE} joystream/node:latest
fi
fi

# Build joystream/apps docker image
echo "Building 'joystream/apps' docker image..."
docker-compose build colossus

# Build the pioneer docker image
echo "Building pioneer docker image"
docker-compose build pioneer
12 changes: 12 additions & 0 deletions build-npm-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -e

yarn
yarn workspace @joystream/types build
yarn workspace @joystream/cd-schemas generate:all
yarn workspace @joystream/cd-schemas build
yarn workspace query-node-root build
yarn workspace @joystream/cli build
yarn workspace storage-node build
yarn workspace pioneer build
50 changes: 0 additions & 50 deletions build.sh

This file was deleted.

7 changes: 3 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,9 @@ services:
- "127.0.0.1:6379:6379"

pioneer:
image: joystream/apps
image: joystream/pioneer
build:
context: .
dockerfile: apps.Dockerfile
dockerfile: pioneer.Dockerfile
ports:
- "127.0.0.1:3000:3000"
command: workspace pioneer start
- "127.0.0.1:3000:80"
4 changes: 2 additions & 2 deletions node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ cd joystream/
Compile the node and runtime:

```bash
WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo build --release
WASM_BUILD_TOOLCHAIN=nightly-2021-02-20 cargo build --release
```

This produces the binary in `./target/release/joystream-node`
Expand Down Expand Up @@ -79,7 +79,7 @@ If you are building a tagged release from `master` branch and want to install th
This will install the executable `joystream-node` to your `~/.cargo/bin` folder, which you would normally have in your `$PATH` environment.

```bash
WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo install joystream-node --path node/ --locked
WASM_BUILD_TOOLCHAIN=nightly-2021-02-20 cargo install joystream-node --path node/ --locked
```

Now you can run and connect to the testnet:
Expand Down
Loading