diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 8d0c7c95c..b1689702f 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 - name: Install dependencies - run: yarn install + run: yarn install --immutable - name: Build run: yarn build:all - name: ESLint @@ -26,3 +26,26 @@ jobs: run: yarn android:bundle - name: Test run: yarn test + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Publish SNJS Docker image for E2E testing + run: | + yarn docker build @standardnotes/snjs -t standardnotes/snjs:${{ github.sha }} + docker push standardnotes/snjs:${{ github.sha }} + docker tag standardnotes/snjs:${{ github.sha }} standardnotes/snjs:test + docker push standardnotes/snjs:test + - name: Run E2E test suite + uses: convictional/trigger-workflow-and-wait@v1.6.1 + with: + owner: standardnotes + repo: e2e + github_token: ${{ secrets.CI_PAT_TOKEN }} + workflow_file_name: testing-with-stable-server.yml + wait_interval: 30 + client_payload: '{"image_tag": "${{ github.sha }}"}' + propagate_failure: true + trigger_workflow: true + wait_workflow: true diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 869f1d0e8..7ae5dca19 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -36,12 +36,45 @@ jobs: git_user_signingkey: true git_commit_gpgsign: true - - name: Install Dependencies + - name: Install dependencies run: yarn install --immutable - - name: Build packages + - name: Build run: yarn build:all + - name: ESLint + run: yarn lint + + - name: Build Android + run: yarn android:bundle + + - name: Test + run: yarn test + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Publish SNJS Docker image for E2E testing + run: | + yarn docker build @standardnotes/snjs -t standardnotes/snjs:${{ github.sha }} + docker push standardnotes/snjs:${{ github.sha }} + + - name: Run E2E test suite + uses: convictional/trigger-workflow-and-wait@v1.6.1 + with: + owner: standardnotes + repo: e2e + github_token: ${{ secrets.CI_PAT_TOKEN }} + workflow_file_name: testing-with-stable-server.yml + wait_interval: 30 + client_payload: '{"image_tag": "${{ github.sha }}"}' + propagate_failure: true + trigger_workflow: true + wait_workflow: true + - name: Bump version run: yarn release:prod @@ -49,3 +82,8 @@ jobs: run: yarn publish:prod env: NODE_AUTH_TOKEN: ${{ secrets.CI_NPM_TOKEN }} + + - name: Publish SNJS Docker image as stable + run: | + docker tag standardnotes/snjs:${{ github.sha }} standardnotes/snjs:latest + docker push standardnotes/snjs:latest diff --git a/.yarn/cache/@sinonjs-samsam-npm-6.1.1-06e18132d0-a09b0914bf.zip b/.yarn/cache/@sinonjs-samsam-npm-6.1.1-06e18132d0-a09b0914bf.zip deleted file mode 100644 index 3188e3d12..000000000 Binary files a/.yarn/cache/@sinonjs-samsam-npm-6.1.1-06e18132d0-a09b0914bf.zip and /dev/null differ diff --git a/.yarn/cache/@sinonjs-text-encoding-npm-0.7.1-865b0079b5-130de0bb56.zip b/.yarn/cache/@sinonjs-text-encoding-npm-0.7.1-865b0079b5-130de0bb56.zip deleted file mode 100644 index b9b97e01e..000000000 Binary files a/.yarn/cache/@sinonjs-text-encoding-npm-0.7.1-865b0079b5-130de0bb56.zip and /dev/null differ diff --git a/.yarn/cache/@ungap-promise-all-settled-npm-1.1.2-c0f42e147b-08d37fdfa2.zip b/.yarn/cache/@ungap-promise-all-settled-npm-1.1.2-c0f42e147b-08d37fdfa2.zip deleted file mode 100644 index 074ceb3e0..000000000 Binary files a/.yarn/cache/@ungap-promise-all-settled-npm-1.1.2-c0f42e147b-08d37fdfa2.zip and /dev/null differ diff --git a/.yarn/cache/ansi-colors-npm-4.1.1-97ad42f223-138d04a510.zip b/.yarn/cache/ansi-colors-npm-4.1.1-97ad42f223-138d04a510.zip deleted file mode 100644 index 19c6d99a7..000000000 Binary files a/.yarn/cache/ansi-colors-npm-4.1.1-97ad42f223-138d04a510.zip and /dev/null differ diff --git a/.yarn/cache/args-npm-5.0.3-ec59f35e6d-ac39e65609.zip b/.yarn/cache/args-npm-5.0.3-ec59f35e6d-ac39e65609.zip deleted file mode 100644 index afa01e95c..000000000 Binary files a/.yarn/cache/args-npm-5.0.3-ec59f35e6d-ac39e65609.zip and /dev/null differ diff --git a/.yarn/cache/browser-stdout-npm-1.3.1-6b2376bf3f-b717b19b25.zip b/.yarn/cache/browser-stdout-npm-1.3.1-6b2376bf3f-b717b19b25.zip deleted file mode 100644 index bf43caa58..000000000 Binary files a/.yarn/cache/browser-stdout-npm-1.3.1-6b2376bf3f-b717b19b25.zip and /dev/null differ diff --git a/.yarn/cache/camelcase-npm-5.0.0-c808398846-8bfe920e04.zip b/.yarn/cache/camelcase-npm-5.0.0-c808398846-8bfe920e04.zip deleted file mode 100644 index cdc64a3c0..000000000 Binary files a/.yarn/cache/camelcase-npm-5.0.0-c808398846-8bfe920e04.zip and /dev/null differ diff --git a/.yarn/cache/chai-as-promised-npm-7.1.1-cdc17e4612-7262868a5b.zip b/.yarn/cache/chai-as-promised-npm-7.1.1-cdc17e4612-7262868a5b.zip deleted file mode 100644 index 947fe7c3c..000000000 Binary files a/.yarn/cache/chai-as-promised-npm-7.1.1-cdc17e4612-7262868a5b.zip and /dev/null differ diff --git a/.yarn/cache/chai-subset-npm-1.6.0-3cee47a65d-c85a64b42d.zip b/.yarn/cache/chai-subset-npm-1.6.0-3cee47a65d-c85a64b42d.zip deleted file mode 100644 index 1b60f97cf..000000000 Binary files a/.yarn/cache/chai-subset-npm-1.6.0-3cee47a65d-c85a64b42d.zip and /dev/null differ diff --git a/.yarn/cache/debug-npm-4.3.3-710fd4cc7f-14472d56fe.zip b/.yarn/cache/debug-npm-4.3.3-710fd4cc7f-14472d56fe.zip deleted file mode 100644 index f2809aaad..000000000 Binary files a/.yarn/cache/debug-npm-4.3.3-710fd4cc7f-14472d56fe.zip and /dev/null differ diff --git a/.yarn/cache/devtools-protocol-npm-0.0.981744-4636a91b0c-609901bff5.zip b/.yarn/cache/devtools-protocol-npm-0.0.981744-4636a91b0c-609901bff5.zip deleted file mode 100644 index 693a9a2e1..000000000 Binary files a/.yarn/cache/devtools-protocol-npm-0.0.981744-4636a91b0c-609901bff5.zip and /dev/null differ diff --git a/.yarn/cache/diff-npm-5.0.0-ad6900db18-f19fe29284.zip b/.yarn/cache/diff-npm-5.0.0-ad6900db18-f19fe29284.zip deleted file mode 100644 index 301b14287..000000000 Binary files a/.yarn/cache/diff-npm-5.0.0-ad6900db18-f19fe29284.zip and /dev/null differ diff --git a/.yarn/cache/extract-zip-npm-2.0.1-92a28e392b-8cbda9debd.zip b/.yarn/cache/extract-zip-npm-2.0.1-92a28e392b-8cbda9debd.zip deleted file mode 100644 index 2169ae491..000000000 Binary files a/.yarn/cache/extract-zip-npm-2.0.1-92a28e392b-8cbda9debd.zip and /dev/null differ diff --git a/.yarn/cache/glob-npm-7.2.0-bb4644d239-78a8ea9423.zip b/.yarn/cache/glob-npm-7.2.0-bb4644d239-78a8ea9423.zip deleted file mode 100644 index 0ef1638a6..000000000 Binary files a/.yarn/cache/glob-npm-7.2.0-bb4644d239-78a8ea9423.zip and /dev/null differ diff --git a/.yarn/cache/growl-npm-1.10.5-2d1da54198-4b86685de6.zip b/.yarn/cache/growl-npm-1.10.5-2d1da54198-4b86685de6.zip deleted file mode 100644 index b05a103da..000000000 Binary files a/.yarn/cache/growl-npm-1.10.5-2d1da54198-4b86685de6.zip and /dev/null differ diff --git a/.yarn/cache/just-extend-npm-4.2.1-ccc4201277-ff9fdede24.zip b/.yarn/cache/just-extend-npm-4.2.1-ccc4201277-ff9fdede24.zip deleted file mode 100644 index 8e6593fad..000000000 Binary files a/.yarn/cache/just-extend-npm-4.2.1-ccc4201277-ff9fdede24.zip and /dev/null differ diff --git a/.yarn/cache/leven-npm-2.1.0-19f0a16606-f7b4a01b15.zip b/.yarn/cache/leven-npm-2.1.0-19f0a16606-f7b4a01b15.zip deleted file mode 100644 index 6eba0706b..000000000 Binary files a/.yarn/cache/leven-npm-2.1.0-19f0a16606-f7b4a01b15.zip and /dev/null differ diff --git a/.yarn/cache/lodash.get-npm-4.4.2-7bda64ed87-e403047ddb.zip b/.yarn/cache/lodash.get-npm-4.4.2-7bda64ed87-e403047ddb.zip deleted file mode 100644 index 63cd7ccfc..000000000 Binary files a/.yarn/cache/lodash.get-npm-4.4.2-7bda64ed87-e403047ddb.zip and /dev/null differ diff --git a/.yarn/cache/minimatch-npm-4.2.1-558ec7f418-2b1514e3d0.zip b/.yarn/cache/minimatch-npm-4.2.1-558ec7f418-2b1514e3d0.zip deleted file mode 100644 index e3bca2199..000000000 Binary files a/.yarn/cache/minimatch-npm-4.2.1-558ec7f418-2b1514e3d0.zip and /dev/null differ diff --git a/.yarn/cache/mocha-headless-chrome-npm-4.0.0-b66897187f-ab802a342d.zip b/.yarn/cache/mocha-headless-chrome-npm-4.0.0-b66897187f-ab802a342d.zip deleted file mode 100644 index d5390cbef..000000000 Binary files a/.yarn/cache/mocha-headless-chrome-npm-4.0.0-b66897187f-ab802a342d.zip and /dev/null differ diff --git a/.yarn/cache/mocha-npm-9.2.2-f7735febb8-4d5ca4ce33.zip b/.yarn/cache/mocha-npm-9.2.2-f7735febb8-4d5ca4ce33.zip deleted file mode 100644 index 11e8b0c72..000000000 Binary files a/.yarn/cache/mocha-npm-9.2.2-f7735febb8-4d5ca4ce33.zip and /dev/null differ diff --git a/.yarn/cache/mri-npm-1.1.4-d22a399f26-e65b9aed3b.zip b/.yarn/cache/mri-npm-1.1.4-d22a399f26-e65b9aed3b.zip deleted file mode 100644 index 5eb6997d6..000000000 Binary files a/.yarn/cache/mri-npm-1.1.4-d22a399f26-e65b9aed3b.zip and /dev/null differ diff --git a/.yarn/cache/nanoid-npm-3.3.1-bdd760bee0-4ef0969e1b.zip b/.yarn/cache/nanoid-npm-3.3.1-bdd760bee0-4ef0969e1b.zip deleted file mode 100644 index 6953ccbb0..000000000 Binary files a/.yarn/cache/nanoid-npm-3.3.1-bdd760bee0-4ef0969e1b.zip and /dev/null differ diff --git a/.yarn/cache/nise-npm-5.1.1-210b3fdf40-d8be29e84a.zip b/.yarn/cache/nise-npm-5.1.1-210b3fdf40-d8be29e84a.zip deleted file mode 100644 index 98d03b105..000000000 Binary files a/.yarn/cache/nise-npm-5.1.1-210b3fdf40-d8be29e84a.zip and /dev/null differ diff --git a/.yarn/cache/proxy-from-env-npm-1.1.0-c13d07f26b-ed7fcc2ba0.zip b/.yarn/cache/proxy-from-env-npm-1.1.0-c13d07f26b-ed7fcc2ba0.zip deleted file mode 100644 index a58e6bf3e..000000000 Binary files a/.yarn/cache/proxy-from-env-npm-1.1.0-c13d07f26b-ed7fcc2ba0.zip and /dev/null differ diff --git a/.yarn/cache/puppeteer-npm-13.7.0-e6812428d2-4062b3ac33.zip b/.yarn/cache/puppeteer-npm-13.7.0-e6812428d2-4062b3ac33.zip deleted file mode 100644 index 2b756cde0..000000000 Binary files a/.yarn/cache/puppeteer-npm-13.7.0-e6812428d2-4062b3ac33.zip and /dev/null differ diff --git a/.yarn/cache/sinon-npm-13.0.2-8544b59862-237f21c8c4.zip b/.yarn/cache/sinon-npm-13.0.2-8544b59862-237f21c8c4.zip deleted file mode 100644 index e68a48c36..000000000 Binary files a/.yarn/cache/sinon-npm-13.0.2-8544b59862-237f21c8c4.zip and /dev/null differ diff --git a/.yarn/cache/unbzip2-stream-npm-1.4.3-c5582d6a9f-0e67c4a91f.zip b/.yarn/cache/unbzip2-stream-npm-1.4.3-c5582d6a9f-0e67c4a91f.zip deleted file mode 100644 index 88b66833a..000000000 Binary files a/.yarn/cache/unbzip2-stream-npm-1.4.3-c5582d6a9f-0e67c4a91f.zip and /dev/null differ diff --git a/.yarn/cache/workerpool-npm-6.2.0-d2a722f6bb-3493b4f0ef.zip b/.yarn/cache/workerpool-npm-6.2.0-d2a722f6bb-3493b4f0ef.zip deleted file mode 100644 index 74dcf5620..000000000 Binary files a/.yarn/cache/workerpool-npm-6.2.0-d2a722f6bb-3493b4f0ef.zip and /dev/null differ diff --git a/.yarn/cache/ws-npm-8.5.0-8e99728c84-76f2f90e40.zip b/.yarn/cache/ws-npm-8.5.0-8e99728c84-76f2f90e40.zip deleted file mode 100644 index 045d2bf79..000000000 Binary files a/.yarn/cache/ws-npm-8.5.0-8e99728c84-76f2f90e40.zip and /dev/null differ diff --git a/.yarn/cache/yargs-parser-npm-20.2.4-1de20916a6-d251998a37.zip b/.yarn/cache/yargs-parser-npm-20.2.4-1de20916a6-d251998a37.zip deleted file mode 100644 index fe57a9c8d..000000000 Binary files a/.yarn/cache/yargs-parser-npm-20.2.4-1de20916a6-d251998a37.zip and /dev/null differ diff --git a/.yarn/plugins/@yarnpkg/plugin-docker-build.cjs b/.yarn/plugins/@yarnpkg/plugin-docker-build.cjs new file mode 100644 index 000000000..a1e572658 --- /dev/null +++ b/.yarn/plugins/@yarnpkg/plugin-docker-build.cjs @@ -0,0 +1,8 @@ +/* eslint-disable */ +module.exports = { +name: "@yarnpkg/plugin-docker-build", +factory: function (require) { +var plugin;(()=>{"use strict";var t={d:(e,o)=>{for(var r in o)t.o(o,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:o[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{default:()=>u});const o=require("@yarnpkg/cli"),r=require("clipanion"),i=require("@yarnpkg/core"),a=require("@yarnpkg/plugin-patch"),n=require("@yarnpkg/fslib");const s=require("@yarnpkg/plugin-pack");async function c({workspace:t,destination:e,report:o}){await s.packUtils.prepareForPack(t,{report:o},async()=>{const r=await s.packUtils.genPackList(t),a=i.Report.progressViaCounter(r.length),c=o.reportProgress(a);try{for(const i of r){const r=n.ppath.join(t.cwd,i),s=n.ppath.join(e,t.relativeCwd,i);o.reportInfo(null,i),await n.xfs.copyPromise(s,r,{overwrite:!0}),a.tick()}}finally{c.stop()}})}function p(t,e){const o=(0,n.toFilename)(e);return n.ppath.isAbsolute(o)?n.ppath.relative(t,o):o}const l=/^builtin<([^>]+)>$/;var d=function(t,e,o,r){var i,a=arguments.length,n=a<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,o,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(n=(a<3?i(n):a>3?i(e,o,n):i(e,o))||n);return a>3&&n&&Object.defineProperty(e,o,n),n};class f extends o.BaseCommand{constructor(){super(...arguments),this.args=[]}async execute(){const t=await i.Configuration.find(this.context.cwd,this.context.plugins),{project:e}=await i.Project.find(t,this.context.cwd),o=e.getWorkspaceByIdent(i.structUtils.parseIdent(this.workspaceName)),r=function({project:t,workspaces:e,production:o=!1,scopes:r=(o?["dependencies"]:i.Manifest.hardDependencies)}){const a=new Set([...e]);for(const e of a)for(const o of r){const r=e.manifest.getForScope(o).values();for(const e of r){const o=t.tryWorkspaceByDescriptor(e);o&&a.add(o)}}for(const e of t.workspaces)a.has(e)?o&&e.manifest.devDependencies.clear():(e.manifest.dependencies.clear(),e.manifest.devDependencies.clear(),e.manifest.peerDependencies.clear());return a}({project:e,workspaces:[o],production:this.production}),s=await async function(t,e="Dockerfile"){const o=(0,n.toFilename)(e);if(n.ppath.isAbsolute(o))return o;const r=[n.ppath.join(t.cwd,o),n.ppath.join(t.project.cwd,o)];for(const t of r)if(await n.xfs.existsPromise(t))return t;throw new Error("Dockerfile is required")}(o,this.dockerFilePath),d=await i.Cache.find(t);return(await i.StreamReport.start({configuration:t,stdout:this.context.stdout,includeLogs:!this.context.quiet},async t=>{await t.startTimerPromise("Resolution Step",async()=>{await e.resolveEverything({report:t,cache:d})}),await t.startTimerPromise("Fetch Step",async()=>{await e.fetchEverything({report:t,cache:d})}),await n.xfs.mktempPromise(async o=>{const f=n.ppath.join(o,(0,n.toFilename)("manifests")),u=n.ppath.join(o,(0,n.toFilename)("packs"));await t.startTimerPromise("Copy files",async()=>{await async function({destination:t,project:e,report:o}){const r=e.configuration.get("rcFilename");o.reportInfo(null,r),await n.xfs.copyPromise(n.ppath.join(t,r),n.ppath.join(e.cwd,r),{overwrite:!0})}({destination:f,project:e,report:t}),await async function({destination:t,project:e,report:o}){const r=n.ppath.join((0,n.toFilename)(".yarn"),(0,n.toFilename)("plugins"));o.reportInfo(null,r),await n.xfs.copyPromise(n.ppath.join(t,r),n.ppath.join(e.cwd,r),{overwrite:!0})}({destination:f,project:e,report:t}),await async function({destination:t,project:e,report:o}){const r=e.configuration.get("yarnPath"),i=n.ppath.relative(e.cwd,r),a=n.ppath.join(t,i);o.reportInfo(null,i),await n.xfs.copyPromise(a,r,{overwrite:!0})}({destination:f,project:e,report:t}),await async function({destination:t,workspaces:e,report:o}){for(const r of e){const e=n.ppath.join(r.relativeCwd,i.Manifest.fileName),a=n.ppath.join(t,e),s={};r.manifest.exportTo(s),o.reportInfo(null,e),await n.xfs.mkdirpPromise(n.ppath.dirname(a)),await n.xfs.writeJsonPromise(a,s)}}({destination:f,workspaces:e.workspaces,report:t}),await async function({destination:t,report:e,project:o,parseDescriptor:r}){const a=new Set;for(const s of o.storedDescriptors.values()){const c=r(i.structUtils.isVirtualDescriptor(s)?i.structUtils.devirtualizeDescriptor(s):s);if(!c)continue;const{parentLocator:p,paths:d}=c;for(const r of d){if(l.test(r))continue;if(n.ppath.isAbsolute(r))continue;const i=o.getWorkspaceByLocator(p),s=n.ppath.join(i.relativeCwd,r);if(a.has(s))continue;a.add(s);const c=n.ppath.join(i.cwd,r),d=n.ppath.join(t,s);e.reportInfo(null,s),await n.xfs.mkdirpPromise(n.ppath.dirname(d)),await n.xfs.copyFilePromise(c,d)}}}({destination:f,report:t,project:e,parseDescriptor:t=>{if(t.range.startsWith("exec:")){const e=function(t){const{params:e,selector:o}=i.structUtils.parseRange(t),r=n.npath.toPortablePath(o);return{parentLocator:e&&"string"==typeof e.locator?i.structUtils.parseLocator(e.locator):null,path:r}}(t.range);if(!e||!e.parentLocator)return;return{parentLocator:e.parentLocator,paths:[e.path]}}if(t.range.startsWith("patch:")){const{parentLocator:e,patchPaths:o}=a.patchUtils.parseDescriptor(t);if(!e)return;return{parentLocator:e,paths:o}}}}),await async function({destination:t,project:e,cache:o,report:r}){for(const i of o.markedFiles){const o=n.ppath.relative(e.cwd,i);await n.xfs.existsPromise(i)&&(r.reportInfo(null,o),await n.xfs.copyPromise(n.ppath.join(t,o),i))}}({destination:f,project:e,cache:d,report:t}),await async function({destination:t,project:e,report:o}){const r=(0,n.toFilename)(e.configuration.get("lockfileFilename")),i=n.ppath.join(t,r);o.reportInfo(null,r),await n.xfs.mkdirpPromise(n.ppath.dirname(i)),await n.xfs.writeFilePromise(i,e.generateLockfile())}({destination:f,project:e,report:t}),this.copyFiles&&this.copyFiles.length&&await async function({destination:t,files:e,dockerFilePath:o,report:r}){const i=n.ppath.dirname(o);for(const o of e){const e=p(i,o),a=n.ppath.join(i,e),s=n.ppath.join(t,e);r.reportInfo(null,e),await n.xfs.copyPromise(s,a)}}({destination:f,files:this.copyFiles,dockerFilePath:s,report:t})});for(const e of r){const o=e.manifest.name?i.structUtils.stringifyIdent(e.manifest.name):"";await t.startTimerPromise("Pack workspace "+o,async()=>{await c({workspace:e,report:t,destination:u})})}await i.execUtils.pipevp("docker",["build",...this.args,"-f",s,"."],{cwd:o,strict:!0,stdin:this.context.stdin,stdout:this.context.stdout,stderr:this.context.stderr})})})).exitCode()}}f.usage=r.Command.Usage({category:"Docker-related commands",description:"Build a Docker image for a workspace",details:'\n This command will build a efficient Docker image which only contains necessary dependencies for the specified workspace.\n\n You have to create a Dockerfile in your workspace or your project. You can also specify the path to Dockerfile using the "-f, --file" option.\n\n Additional arguments can be passed to "docker build" directly, please check the Docker docs for more info: https://docs.docker.com/engine/reference/commandline/build/\n\n You can copy additional files or folders to a Docker image using the "--copy" option. This is useful for secret keys or configuration files. The files will be copied to "manifests" folder. The path can be either a path relative to the Dockerfile or an absolute path.\n ',examples:[["Build a Docker image for a workspace","yarn docker build @foo/bar"],["Pass additional arguments to docker build command","yarn docker build @foo/bar -t image-tag"],["Copy additional files to a Docker image","yarn docker build --copy secret.key --copy config.json @foo/bar"],["Install production dependencies only","yarn docker build --production @foo/bar"]]}),d([r.Command.String()],f.prototype,"workspaceName",void 0),d([r.Command.Proxy()],f.prototype,"args",void 0),d([r.Command.String("-f,--file")],f.prototype,"dockerFilePath",void 0),d([r.Command.Array("--copy")],f.prototype,"copyFiles",void 0),d([r.Command.Boolean("--production")],f.prototype,"production",void 0),d([r.Command.Path("docker","build")],f.prototype,"execute",null);const u={commands:[f]};plugin=e})(); +return plugin; +} +}; \ No newline at end of file diff --git a/.yarnrc.yml b/.yarnrc.yml index 4c6afad73..3097ba20c 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -24,5 +24,7 @@ plugins: spec: "@yarnpkg/plugin-workspace-tools" - path: .yarn/plugins/@yarnpkg/plugin-version.cjs spec: "@yarnpkg/plugin-version" + - path: .yarn/plugins/@yarnpkg/plugin-docker-build.cjs + spec: "https://github.com/Dcard/yarn-plugins/releases/latest/download/plugin-docker-build.js" yarnPath: .yarn/releases/yarn-3.2.1.cjs diff --git a/packages/snjs/.gitignore b/packages/snjs/.gitignore new file mode 100644 index 000000000..475745ded --- /dev/null +++ b/packages/snjs/.gitignore @@ -0,0 +1 @@ +mocha/vendor/sncrypto-web.js diff --git a/packages/snjs/Dockerfile b/packages/snjs/Dockerfile new file mode 100644 index 000000000..2a4d15e1b --- /dev/null +++ b/packages/snjs/Dockerfile @@ -0,0 +1,25 @@ +FROM node:16.15.1-alpine AS builder + +# Install dependencies for building native libraries +RUN apk add --update git openssh-client python3 alpine-sdk + +WORKDIR /workspace + +# docker-build plugin copies everything needed for `yarn install` to `manifests` folder. +COPY manifests ./ + +RUN yarn install --immutable + +FROM node:16.15.1-alpine + +RUN apk add --update curl + +WORKDIR /workspace + +# Copy the installed dependencies from the previous stage. +COPY --from=builder /workspace ./ + +# docker-build plugin runs `yarn pack` in all workspace dependencies and copies them to `packs` folder. +COPY packs ./ + +CMD [ "yarn", "start:test-server" ] diff --git a/packages/snjs/e2e-server.js b/packages/snjs/e2e-server.js new file mode 100644 index 000000000..4ade36f2e --- /dev/null +++ b/packages/snjs/e2e-server.js @@ -0,0 +1,29 @@ +/* Used for running mocha tests */ +const connect = require('connect') +const serveStatic = require('serve-static') +const fs = require('fs') + +const isDev = process.argv[2] === '--dev' +const port = isDev ? 9002 : 9001 + +const snCryptoDistFilePath = `${__dirname}/../sncrypto-web/dist/sncrypto-web.js` +if (!fs.existsSync(snCryptoDistFilePath)) { + console.error( + `Could not find sncrypto dist file under: ${snCryptoDistFilePath}. Please consider building the project first`, + ) + + process.exit(1) +} + +fs.copyFileSync(snCryptoDistFilePath, `${__dirname}/mocha/vendor/sncrypto-web.js`) + +connect() + .use(serveStatic(__dirname)) + .listen(port, () => { + const url = `http://localhost:${port}/mocha/test.html` + console.log(`Test Server Started on ${url}`) + if (!isDev) { + const start = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open' + require('child_process').exec(start + ' ' + url) + } + }) diff --git a/packages/snjs/mocha/test.html b/packages/snjs/mocha/test.html index 742c78e7a..d38360c32 100644 --- a/packages/snjs/mocha/test.html +++ b/packages/snjs/mocha/test.html @@ -4,13 +4,13 @@