2018-10-29 20:36:14 -07:00
|
|
|
version: 2.1
|
2018-10-29 05:48:35 -07:00
|
|
|
|
2018-10-29 20:36:14 -07:00
|
|
|
executors:
|
|
|
|
default:
|
|
|
|
working_directory: /tmp/workspace
|
|
|
|
docker:
|
|
|
|
- image: misskey/ci:latest
|
|
|
|
- image: circleci/mongo:latest
|
|
|
|
- image: circleci/redis:latest
|
|
|
|
docker:
|
|
|
|
working_directory: /tmp/workspace
|
2018-10-26 11:46:48 -07:00
|
|
|
docker:
|
2018-10-29 20:36:14 -07:00
|
|
|
- image: docker:latest
|
2018-11-08 01:49:45 -08:00
|
|
|
alpine:
|
|
|
|
working_directory: /tmp/workspace
|
|
|
|
docker:
|
|
|
|
- image: alpine:latest
|
2018-10-29 20:36:14 -07:00
|
|
|
|
|
|
|
jobs:
|
2018-11-08 01:49:45 -08:00
|
|
|
ok:
|
|
|
|
executor: alpine
|
|
|
|
steps:
|
|
|
|
- run:
|
|
|
|
name: OK
|
|
|
|
command: |
|
|
|
|
echo -e '\033[0;32mOK\033[0;39m'
|
|
|
|
|
2018-10-29 20:36:14 -07:00
|
|
|
build:
|
|
|
|
executor: default
|
2018-10-26 11:46:48 -07:00
|
|
|
steps:
|
|
|
|
- checkout
|
2018-11-05 00:38:57 -08:00
|
|
|
- run:
|
|
|
|
name: Ensure package-lock.json
|
|
|
|
command: |
|
|
|
|
[ ! -e package-lock.json ] && echo '{}' > package-lock.json
|
2018-10-29 20:36:14 -07:00
|
|
|
- restore_cache:
|
|
|
|
name: Restore npm package caches
|
|
|
|
keys:
|
|
|
|
- npm-v1-arch-{{ arch }}-env-{{ .Environment.variableName }}-package-{{ checksum "package.json" }}-lock-{{ checksum "package-lock.json" }}-
|
|
|
|
- npm-v1-arch-{{ arch }}-env-{{ .Environment.variableName }}-package-{{ checksum "package.json" }}-
|
|
|
|
- npm-v1-arch-{{ arch }}-env-{{ .Environment.variableName }}-
|
|
|
|
- npm-v1-arch-{{ arch }}-
|
|
|
|
- npm-v1-
|
2018-10-26 11:46:48 -07:00
|
|
|
- run:
|
2018-10-29 20:36:14 -07:00
|
|
|
name: Install Dependencies
|
2018-10-26 11:46:48 -07:00
|
|
|
command: |
|
2018-10-29 20:36:14 -07:00
|
|
|
npm install
|
2018-11-05 00:38:57 -08:00
|
|
|
npm prune
|
2018-10-26 11:46:48 -07:00
|
|
|
- run:
|
2018-10-29 20:36:14 -07:00
|
|
|
name: Configure
|
2018-10-26 11:46:48 -07:00
|
|
|
command: |
|
2018-11-05 13:12:51 -08:00
|
|
|
cp .circleci/misskey/default.yml .config
|
|
|
|
cp .circleci/misskey/test.yml .config
|
2018-10-26 11:46:48 -07:00
|
|
|
- run:
|
2018-10-29 20:36:14 -07:00
|
|
|
name: Build
|
2018-10-26 11:46:48 -07:00
|
|
|
command: |
|
2018-10-29 20:36:14 -07:00
|
|
|
npm run build || (echo -e '\033[0;34mRebuild modules\033[0;39m' && ls -1A node_modules | grep '^[^@]' | xargs npm rebuild && ls -1A node_modules | grep '^@' | xargs -I%1 sh -c 'ls -1A node_modules/'%1' | xargs -P0 -I%2 npm rebuild node_modules/'%1'/%2' && npm run build)
|
|
|
|
ls -1ARl node_modules > ls
|
|
|
|
- save_cache:
|
|
|
|
name: Cache npm packages
|
|
|
|
key: npm-v1-arch-{{ arch }}-env-{{ .Environment.variableName }}-package-{{ checksum "package.json" }}-lock-{{ checksum "package-lock.json" }}-ls-{{ checksum "ls" }}
|
|
|
|
paths:
|
|
|
|
- node_modules
|
2018-11-05 00:38:57 -08:00
|
|
|
# - store_artifacts:
|
|
|
|
# path: built
|
2018-10-29 20:36:14 -07:00
|
|
|
- persist_to_workspace:
|
|
|
|
root: .
|
|
|
|
paths:
|
|
|
|
- .
|
|
|
|
test:
|
|
|
|
parameters:
|
|
|
|
without_redis:
|
|
|
|
type: string
|
|
|
|
default: ""
|
|
|
|
executor: default
|
|
|
|
steps:
|
|
|
|
- attach_workspace:
|
|
|
|
at: /tmp/workspace
|
|
|
|
- when:
|
|
|
|
condition: <<parameters.without_redis>>
|
|
|
|
steps:
|
|
|
|
- run:
|
|
|
|
name: Configure
|
|
|
|
command: |
|
|
|
|
mv .config/test.yml .config/test_redis.yml
|
|
|
|
touch .config/test.yml
|
|
|
|
cat .config/test_redis.yml | while IFS= read line; do if [[ "$line" = '# __REDIS__' ]]; then break; else echo "$line" >> .config/test.yml; fi; done
|
2018-10-26 11:46:48 -07:00
|
|
|
- run:
|
2018-10-29 20:36:14 -07:00
|
|
|
name: Test
|
2018-10-26 11:46:48 -07:00
|
|
|
command: |
|
2018-10-29 20:36:14 -07:00
|
|
|
npm run test || (npm rebuild && npm run test) || ((node-gyp configure && node-gyp build && npm run build || (echo -e '\033[0;34mRebuild modules\033[0;39m' && ls -1A node_modules | grep '^[^@]' | xargs npm rebuild && ls -1A node_modules | grep '^@' | xargs -I%1 sh -c 'ls -1A node_modules/'%1' | xargs -P0 -I%2 npm rebuild node_modules/'%1'/%2' && npm run build)) && npm run test)
|
|
|
|
ls -1ARl node_modules > ls
|
|
|
|
- save_cache:
|
|
|
|
name: Cache npm packages
|
|
|
|
key: npm-v1-arch-{{ arch }}-env-{{ .Environment.variableName }}-package-{{ checksum "package.json" }}-lock-{{ checksum "package-lock.json" }}-ls-{{ checksum "ls" }}
|
|
|
|
paths:
|
|
|
|
- node_modules
|
|
|
|
|
|
|
|
docker:
|
|
|
|
parameters:
|
|
|
|
with_deploy:
|
|
|
|
type: string
|
|
|
|
default: ""
|
|
|
|
executor: docker
|
2018-10-26 11:46:48 -07:00
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- setup_remote_docker
|
|
|
|
- run:
|
2018-10-29 20:36:14 -07:00
|
|
|
name: Build
|
2018-10-26 11:46:48 -07:00
|
|
|
command: |
|
2018-11-06 09:06:32 -08:00
|
|
|
docker build -t misskey/misskey .
|
2018-10-29 20:36:14 -07:00
|
|
|
- when:
|
|
|
|
condition: <<parameters.with_deploy>>
|
|
|
|
steps:
|
|
|
|
- run:
|
|
|
|
name: Deploy
|
|
|
|
command: |
|
2018-10-31 06:00:21 -07:00
|
|
|
if [ "$DOCKERHUB_USERNAME$DOCKERHUB_PASSWORD" ]
|
|
|
|
then
|
2018-11-08 01:49:45 -08:00
|
|
|
curl -LSs 'https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64' > jq
|
|
|
|
chmod +x jq
|
|
|
|
docker tag misskey/misskey misskey/misskey:$(cat package.json | jq -r .version)
|
2018-10-31 06:00:21 -07:00
|
|
|
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
|
|
|
|
docker push misskey/misskey
|
|
|
|
else
|
|
|
|
echo -e '\033[0;33mAborted deploying to Docker Hub\033[0;39m'
|
|
|
|
fi
|
2018-10-26 11:46:48 -07:00
|
|
|
|
|
|
|
workflows:
|
|
|
|
version: 2
|
2018-10-29 20:36:14 -07:00
|
|
|
build-and-test:
|
2018-10-26 11:46:48 -07:00
|
|
|
jobs:
|
2018-11-08 01:49:45 -08:00
|
|
|
- ok:
|
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only:
|
|
|
|
- l10n_develop
|
|
|
|
- imgbot
|
|
|
|
- build:
|
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
ignore:
|
|
|
|
- l10n_develop
|
|
|
|
- imgbot
|
2018-10-29 20:36:14 -07:00
|
|
|
- test:
|
|
|
|
requires:
|
|
|
|
- build
|
2018-11-08 01:49:45 -08:00
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
ignore:
|
|
|
|
# - master
|
|
|
|
- l10n_develop
|
|
|
|
- imgbot
|
2018-10-29 20:36:14 -07:00
|
|
|
- test:
|
|
|
|
without_redis: "true"
|
|
|
|
requires:
|
|
|
|
- build
|
|
|
|
filters:
|
|
|
|
branches:
|
2018-11-05 00:38:57 -08:00
|
|
|
only: master
|
|
|
|
# - docker:
|
|
|
|
# filters:
|
|
|
|
# branches:
|
|
|
|
# ignore: master
|
2018-10-29 20:36:14 -07:00
|
|
|
- docker:
|
|
|
|
with_deploy: "true"
|
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only: master
|