Files
speckle-server/.circleci/config.yml
T
Gergő Jedlicska 638969cd01 gergo/yarn (#753)
* yarn first go

* fix frontend build cache loader

* yarn workspaces built server Docker

* build(yarn): add workspaces plugin config

* chore(package defs): clean package*.json -s

* chore(gitignore): ignore yarn error log

* build(yarn): update yarn lock

* build(preview-service webpack): add extra resolved path to preview service webpack config

because of yarn package hoisting, there are no package level node_modules folder anymore.

* build(docker): update dockerignore with yarn specific configs

* build(docker): update Dockerfiles for yarn workspaces utilization

* ci(circleci): update server test job to yarn

* ci(circle): disable cache restore

* ci(circleci): trying the node orb yarn-run

* ci(circleci): yarn-run again

* ci(circleci): disable node orb

* ci(circleci): change base node image for tests

* ci(circleci): add yarn cache

* ci(circleci): remove node install step

* ci(circleci): add server specific cache archives

* ci(circleci): test build and publish

* ci(circleci): change npm auth method to suit yarn

* ci(circleci): trying new builder image

* ci(circleci): another base image, maybe this works

* ci(circleci): force a specific docker engine version

* ci(circleci): add yarn version plugin and its changes

* ci(circleci): cleanup and remove temp branch config

* chore(package defs): moving from npm run to yarn

* explicitly specifying webpack4 as a frontend dep

* chore(package defs): replace npm with yarn everywhere

* docs(root readme): update with some yarn specific docs

* chore(root workspace): update dev scripts and package lock

* ci(circleci): enable package publish step with yarn

Co-authored-by: Fabians <fabis94@live.com>
2022-05-19 19:53:07 +02:00

292 lines
7.8 KiB
YAML

version: 2.1
workflows:
version: 2
test-build:
jobs:
- test-server:
filters:
tags:
# run tests for all tags
only: /.*/
- get-version:
filters: &filters-build
tags:
only: &filters-tag /^[0-9]+\.[0-9]+\.[0-9]+$/
branches:
only:
- main
- docker-build-and-publish-server:
filters: *filters-build
context: &docker-hub-context
- docker-hub
requires:
- test-server
- get-version
- docker-build-and-publish-frontend:
context: *docker-hub-context
filters: *filters-build
requires:
- get-version
- docker-build-and-publish-webhooks:
context: *docker-hub-context
filters: *filters-build
requires:
- get-version
- test-server
- docker-build-and-publish-file-imports:
context: *docker-hub-context
filters: *filters-build
requires:
- get-version
- test-server
- docker-build-and-publish-previews:
context: *docker-hub-context
filters: *filters-build
requires:
- get-version
- test-server
- docker-build-and-publish-test-container:
context: *docker-hub-context
filters: *filters-build
requires:
- get-version
- test-server
- docker-build-and-publish-monitor-container:
context: *docker-hub-context
filters: *filters-build
requires:
- get-version
- publish-helm-chart:
filters: *filters-build
requires:
- test-server
- get-version
- docker-build-and-publish-server
- docker-build-and-publish-frontend
- docker-build-and-publish-webhooks
- docker-build-and-publish-file-imports
- docker-build-and-publish-previews
- docker-build-and-publish-monitor-container
- docker-build-and-publish-test-container
- publish-npm:
filters:
tags:
only: *filters-tag
branches:
ignore: /.*/
context:
- npm-registry
requires:
- get-version
jobs:
get-version:
docker:
- image: cimg/python:3.9
working_directory: &work-dir /tmp/ci
steps:
- checkout
- run: pwd
- run: mkdir -p workspace
- run:
name: set version
command: |
echo "export IMAGE_VERSION_TAG=$(.circleci/get_version.sh)" >> workspace/env-vars
- run: cat workspace/env-vars >> $BASH_ENV
- run: echo $IMAGE_VERSION_TAG
# - run: sleep 3m
- persist_to_workspace:
root: workspace
paths:
- env-vars
test-server:
docker:
- image: cimg/node:16.15
- image: cimg/redis:6.2.6
- image: 'cimg/postgres:12.8'
environment:
POSTGRES_DB: speckle2_test
POSTGRES_PASSWORD: speckle
POSTGRES_USER: speckle
environment:
NODE_ENV: test
DATABASE_URL: 'postgres://speckle:speckle@localhost:5432/speckle2_test'
PGDATABASE: speckle2_test
PGUSER: speckle
SESSION_SECRET: 'keyboard cat'
STRATEGY_LOCAL: 'true'
CANONICAL_URL: 'http://localhost:3000'
steps:
- checkout
- restore_cache:
name: Restore Yarn Package Cache
keys:
- yarn-packages-server-{{ checksum "yarn.lock" }}
- run:
name: Install Dependencies
command: yarn workspaces focus
working_directory: 'packages/server'
- save_cache:
name: Save Yarn Package Cache
key: yarn-packages-server-{{ checksum "yarn.lock" }}
paths:
- .yarn/cache
- .yarn/unplugged
- run: 'dockerize -wait tcp://localhost:5432 -timeout 1m'
- run:
command: touch .env.test
working_directory: 'packages/server'
- run:
command: yarn test:report
working_directory: 'packages/server'
- run:
command: 'bash <(curl -s https://codecov.io/bash)'
working_directory: 'packages/server'
- store_test_results:
path: packages/server/reports
- store_artifacts:
path: packages/server/coverage/lcov-report
destination: package/server/coverage
docker-build-and-publish: &docker-job
docker: &docker-image
- image: cimg/node:16.15
working_directory: *work-dir
steps:
- checkout
- attach_workspace:
at: /tmp/ci/workspace
- run: cat workspace/env-vars >> $BASH_ENV
- setup_remote_docker:
# a weird issue with yarn installing packages throwing EPERM errors
# this fixes it
version: 20.10.12
docker_layer_caching: true
- run:
name: Build and Publish
command: ./.circleci/build.sh
docker-build-and-publish-server:
<<: *docker-job
environment:
SPECKLE_SERVER_PACKAGE: server
docker-build-and-publish-frontend:
<<: *docker-job
environment:
SPECKLE_SERVER_PACKAGE: frontend
docker-build-and-publish-previews:
<<: *docker-job
environment:
SPECKLE_SERVER_PACKAGE: preview-service
docker-build-and-publish-webhooks:
<<: *docker-job
environment:
SPECKLE_SERVER_PACKAGE: webhook-service
docker-build-and-publish-file-imports:
<<: *docker-job
environment:
SPECKLE_SERVER_PACKAGE: fileimport-service
docker-build-and-publish-test-container:
<<: *docker-job
environment:
FOLDER: utils
SPECKLE_SERVER_PACKAGE: test-deployment
docker-build-and-publish-monitor-container:
<<: *docker-job
environment:
FOLDER: utils
SPECKLE_SERVER_PACKAGE: monitor-deployment
publish-npm:
docker: *docker-image
working_directory: *work-dir
steps:
- checkout
- attach_workspace:
at: /tmp/ci/workspace
- run: cat workspace/env-vars >> $BASH_ENV
- restore_cache:
name: Restore Yarn Package Cache
keys:
- yarn-packages-{{ checksum "yarn.lock" }}
- run:
name: Install Dependencies
command: yarn
- save_cache:
name: Save Yarn Package Cache
key: yarn-packages-{{ checksum "yarn.lock" }}
paths:
- .yarn/cache
- .yarn/unplugged
- run:
name: auth to npm as Speckle
command: |
echo "npmRegistryServer: https://registry.npmjs.org/" >> .yarnrc.yml
echo "npmAuthToken: ${NPM_TOKEN}" >> .yarnrc.yml
- run:
name: try login to npm
command: yarn npm whoami
- run:
name: build public packages
command: yarn workspaces foreach -ptv --no-private run build
- run:
name: bump all versions
# bump all versions in dependency tree order but not in parallel
command: yarn workspaces foreach -tv version $IMAGE_VERSION_TAG
- run:
name: publish to npm
command: 'yarn workspaces foreach -pv --no-private npm publish --access public --tag next'
# - run:
# name: commit changes
# command: |
# yarn prettier:fix
# git add .
# git commit -m '[ci skip] bump version to $IMAGE_VERSION_TAG'
# git push
publish-helm-chart:
docker: *docker-image
working_directory: *work-dir
steps:
- checkout
- attach_workspace:
at: /tmp/ci/workspace
- run: cat workspace/env-vars >> $BASH_ENV
- add_ssh_keys:
fingerprints:
- '18:74:c4:b9:dc:66:b2:66:1d:81:56:0d:0a:87:9b:b1'
- run:
name: Publish Helm Chart
command: ./.circleci/publish_helm_chart.sh