mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-06-07 02:15:01 -04:00
ci: install node dependencies
This commit is contained in:
parent
fc13557fa6
commit
447cac13ec
5 changed files with 42 additions and 145 deletions
|
@ -1,137 +0,0 @@
|
||||||
version: 2.1
|
|
||||||
orbs:
|
|
||||||
browser-tools: circleci/browser-tools@1
|
|
||||||
node: circleci/node@5
|
|
||||||
aliases:
|
|
||||||
- &defaults
|
|
||||||
docker:
|
|
||||||
- image: cimg/node:16.20-browsers
|
|
||||||
auth:
|
|
||||||
username: $DOCKERHUB_USERNAME
|
|
||||||
password: $DOCKERHUB_PASSWORD
|
|
||||||
commands:
|
|
||||||
install_python2:
|
|
||||||
steps:
|
|
||||||
- run:
|
|
||||||
name: Install Python 2
|
|
||||||
command: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install python2-minimal
|
|
||||||
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 10
|
|
||||||
test:
|
|
||||||
steps:
|
|
||||||
- run:
|
|
||||||
name: Test
|
|
||||||
# The "cimg/node:*-browsers" images run Xvfb on :99 at startup, but that doesn't seem to be documented.
|
|
||||||
# If this starts failing, that might no longer be true.
|
|
||||||
# In that case, try: xvfb-run -e /dev/stdout npm test
|
|
||||||
command: DISPLAY=:99 npm test
|
|
||||||
deploy_gh_pages:
|
|
||||||
steps:
|
|
||||||
- when:
|
|
||||||
condition:
|
|
||||||
or:
|
|
||||||
- equal: [ master, <<pipeline.git.branch>> ]
|
|
||||||
- equal: [ develop, <<pipeline.git.branch>> ]
|
|
||||||
steps:
|
|
||||||
- run:
|
|
||||||
name: Deploy to GH Pages
|
|
||||||
command: |
|
|
||||||
git config --global user.email $(git log --pretty=format:"%ae" -n1)
|
|
||||||
git config --global user.name $(git log --pretty=format:"%an" -n1)
|
|
||||||
npm run deploy -- \
|
|
||||||
-r https://${GH_TOKEN}@github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}.git
|
|
||||||
deploy_npm:
|
|
||||||
steps:
|
|
||||||
- when:
|
|
||||||
condition:
|
|
||||||
or:
|
|
||||||
- equal: [ master, <<pipeline.git.branch>> ]
|
|
||||||
- equal: [ develop, <<pipeline.git.branch>> ]
|
|
||||||
- equal: [ beta, <<pipeline.git.branch>> ]
|
|
||||||
- matches: { pattern: "^hotfix.*", value: <<pipeline.git.branch>> }
|
|
||||||
- matches: { pattern: "^release.*", value: <<pipeline.git.branch>> }
|
|
||||||
steps:
|
|
||||||
- run:
|
|
||||||
# This relies on deploy_gh_pages to set git user info first
|
|
||||||
name: Deploy to NPM
|
|
||||||
command: |
|
|
||||||
export RELEASE_VERSION="0.2.0-prerelease.$(date +'%Y%m%d%H%M%S')"
|
|
||||||
if [[ "$CIRCLE_BRANCH" == hotfix/* ]]; then
|
|
||||||
export NPM_TAG=hotfix
|
|
||||||
elif [[ "$CIRCLE_BRANCH" == beta ]]; then
|
|
||||||
export NPM_TAG=beta
|
|
||||||
else
|
|
||||||
export NPM_TAG=latest
|
|
||||||
fi
|
|
||||||
echo "Deploying version $RELEASE_VERSION to $NPM_TAG"
|
|
||||||
npm --no-git-tag-version version $RELEASE_VERSION
|
|
||||||
npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
|
|
||||||
npm publish --tag $NPM_TAG
|
|
||||||
if npm info | grep -q $RELEASE_VERSION; then
|
|
||||||
git tag $RELEASE_VERSION
|
|
||||||
git push \
|
|
||||||
https://${GH_TOKEN}@github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}.git \
|
|
||||||
$RELEASE_VERSION
|
|
||||||
fi
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
default:
|
|
||||||
<<: *defaults
|
|
||||||
environment:
|
|
||||||
# DETECT_CHROMEDRIVER_VERSION only works if Chrome is installed before installing NPM packages
|
|
||||||
DETECT_CHROMEDRIVER_VERSION: "true"
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- install_python2
|
|
||||||
- browser-tools/install-chrome
|
|
||||||
- node/install-packages
|
|
||||||
- test
|
|
||||||
- deploy_gh_pages
|
|
||||||
- deploy_npm
|
|
||||||
sync_translations:
|
|
||||||
<<: *defaults
|
|
||||||
steps:
|
|
||||||
- run:
|
|
||||||
name: Sync Translations
|
|
||||||
command: |
|
|
||||||
echo "Starting translation sync"
|
|
||||||
set -ev
|
|
||||||
git checkout develop
|
|
||||||
# update translations, and test any updated messages
|
|
||||||
npm run translate
|
|
||||||
npm run translate:update
|
|
||||||
npm run test:messages
|
|
||||||
# stage any changes in the msg directory
|
|
||||||
git add ./msg
|
|
||||||
if git diff --cached --exit-code --quiet; then
|
|
||||||
echo "Nothing to commit."
|
|
||||||
else
|
|
||||||
git commit -m 'Update translations from Transifex [skip ci]'
|
|
||||||
# add remote, make sure that API token doesn't end up in the log
|
|
||||||
git remote add origin-translation \
|
|
||||||
https://${GH_TOKEN}@github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}.git \
|
|
||||||
> /dev/null 2>&1
|
|
||||||
git push --set-upstream origin-translation develop
|
|
||||||
fi
|
|
||||||
workflows:
|
|
||||||
version: 2
|
|
||||||
default:
|
|
||||||
jobs:
|
|
||||||
- default:
|
|
||||||
context:
|
|
||||||
- dockerhub-credentials
|
|
||||||
- scratch-npm-creds
|
|
||||||
sync_translations:
|
|
||||||
triggers:
|
|
||||||
- schedule:
|
|
||||||
cron: 0 0 * * 1 # weekly on Monday
|
|
||||||
filters:
|
|
||||||
branches:
|
|
||||||
only:
|
|
||||||
- develop
|
|
||||||
jobs:
|
|
||||||
- sync_translations:
|
|
||||||
context:
|
|
||||||
- dockerhub-credentials
|
|
||||||
- scratch-npm-creds
|
|
|
@ -14,3 +14,5 @@
|
||||||
/gh-pages/*
|
/gh-pages/*
|
||||||
/webpack.config.js
|
/webpack.config.js
|
||||||
/build/*
|
/build/*
|
||||||
|
|
||||||
|
/github-pages/*
|
||||||
|
|
40
.github/workflows/deploy.yml
vendored
40
.github/workflows/deploy.yml
vendored
|
@ -1,16 +1,46 @@
|
||||||
name: build-scratch-blocks
|
name: build-scratch-blocks
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
permissions: write-all
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
setup:
|
setup:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
JVM_OPTS: -Xmx3200m
|
||||||
|
DETECT_CHROMEDRIVER_VERSION: "true"
|
||||||
|
PROJECT_PATH: ./scratch-blocks
|
||||||
container:
|
container:
|
||||||
image: python:2.7.18-buster
|
image: python:2.7.18-buster
|
||||||
|
options: --user root
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Node
|
- name: Install Chrome Dependencies
|
||||||
uses: actions/setup-node@v2
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y libgconf-2-4 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm-dev libnss3-dev libxss-dev libasound2
|
||||||
|
- name: Check Python version
|
||||||
|
run: python --version
|
||||||
|
- name: Setup Java
|
||||||
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
node-version: 16
|
distribution: 'temurin'
|
||||||
|
java-version: 17
|
||||||
|
- name: Setup Node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version-file: '.nvmrc'
|
||||||
|
# - name: Setup Chrome
|
||||||
|
# uses: browser-actions/setup-chrome@v1
|
||||||
|
# with:
|
||||||
|
# chrome-version: latest
|
||||||
- name: Install Node Dependencies
|
- name: Install Node Dependencies
|
||||||
run: node -v
|
run: npm ci
|
||||||
|
- name: Lint
|
||||||
|
run: npm run test:lint
|
||||||
|
- name: Whats In Here
|
||||||
|
run: ls -la
|
||||||
|
- name: MSG
|
||||||
|
run: cd msg && ls -la
|
||||||
|
- name: Run Tests
|
||||||
|
run: npm test
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
"test:unit": "node tests/jsunit/test_runner.js",
|
"test:unit": "node tests/jsunit/test_runner.js",
|
||||||
"test:lint": "eslint .",
|
"test:lint": "eslint .",
|
||||||
"test:messages": "npm run translate && node i18n/test_scratch_msgs.js",
|
"test:messages": "npm run translate && node i18n/test_scratch_msgs.js",
|
||||||
"test": "npm run test:lint && npm run test:messages && npm run test:unit",
|
"test": "npm run test:messages && npm run test:unit",
|
||||||
"version": "json -f package.json -I -e \"this.repository.sha = '$(git log -n1 --pretty=format:%H)'\"",
|
"version": "json -f package.json -I -e \"this.repository.sha = '$(git log -n1 --pretty=format:%H)'\"",
|
||||||
"translate": "node i18n/js_to_json.js && node i18n/json_to_js.js",
|
"translate": "node i18n/js_to_json.js && node i18n/json_to_js.js",
|
||||||
"translate:sync:src": "tx-push-src scratch-editor blocks msg/json/en.json",
|
"translate:sync:src": "tx-push-src scratch-editor blocks msg/json/en.json",
|
||||||
|
@ -48,4 +48,4 @@
|
||||||
"webpack": "4.47.0",
|
"webpack": "4.47.0",
|
||||||
"webpack-cli": "3.3.12"
|
"webpack-cli": "3.3.12"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ var CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var UglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
var UglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = [{
|
module.exports = [{
|
||||||
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
|
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
|
||||||
entry: {
|
entry: {
|
||||||
|
@ -53,7 +55,7 @@ module.exports = [{
|
||||||
entry: './shim/gh-pages.js',
|
entry: './shim/gh-pages.js',
|
||||||
output: {
|
output: {
|
||||||
filename: '[name].js',
|
filename: '[name].js',
|
||||||
path: path.resolve(__dirname, 'gh-pages')
|
path: path.resolve(__dirname, 'github-pages') //'/__w/scratch-blocks/scratch-blocks/github-pages'
|
||||||
},
|
},
|
||||||
optimization: {
|
optimization: {
|
||||||
minimize: false
|
minimize: false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue