Browse Source

chore: Fix publish & install workflow (#167)

* chore: Fix publish & install workflow

* chore(create): Specify Vendure package versions for CI

* chore(create): Increase yarn network timeout in CI mode

* chore: Specify other Node version for workflow

* chore: Update Yarn for CI workflow

* chore: Use npm to install in CI

* chore: Update verdaccio config for CI

* chore: Fiddle with some Verdaccio config values
Michael Bromley 6 years ago
parent
commit
d5ccc25ee6

+ 9 - 3
.github/workflows/publish_and_install.yml

@@ -16,7 +16,13 @@ jobs:
     - name: Use Node.js 12.x
       uses: actions/setup-node@v1
       with:
-        node-version: 12.x
+        node-version: 12.4.x
+    - name: Update Yarn
+      run: |
+        curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
+        echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
+        sudo apt-get update && sudo apt-get install yarn
+        yarn --version
     - name: Install & bootstrap
       run: |
         yarn install
@@ -34,10 +40,10 @@ jobs:
         npm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}
         npm set //localhost:4873/:_authToken=${{ secrets.VERDACCIO_AUTH_TOKEN }}
         npm set registry=http://localhost:4873/
-        yarn lerna publish prepatch --preid ci --no-push --no-git-tag-version --no-commit-hooks --yes --dist-tag ci --registry http://localhost:4873/
+        yarn lerna publish prepatch --preid ci --no-push --no-git-tag-version --no-commit-hooks --force-publish "*" --yes --dist-tag ci --registry http://localhost:4873/
     - name: Install via @vendure/create
       run: |
         mkdir -p $HOME/install
         cd $HOME/install
         npm dist-tag ls @vendure/create
-        npx @vendure/create@ci test-app --ci
+        npx @vendure/create@ci test-app --ci --use-npm --log-level verbose

+ 8 - 5
.github/workflows/verdaccio/config.yaml

@@ -27,6 +27,9 @@ auth:
 uplinks:
   npmjs:
     url: https://registry.npmjs.org/
+    timeout: 5m
+    max_fails: 10
+    cache: false
 
 packages:
   '@*/*':
@@ -54,15 +57,15 @@ packages:
 # A value of 0 makes the http server behave similarly to Node.js versions prior to 8.0.0, which did not have a keep-alive timeout.
 # WORKAROUND: Through given configuration you can workaround following issue https://github.com/verdaccio/verdaccio/issues/301. Set to 0 in case 60 is not enought.
 server:
-  keepAliveTimeout: 60
+  keepAliveTimeout: 0
 
 # To use `npm audit` uncomment the following section
-middlewares:
-  audit:
-    enabled: true
+# middlewares:
+#   audit:
+#     enabled: true
 
 # log settings
 logs:
-  - {type: stdout, format: pretty, level: debug}
+  - {type: stdout, format: pretty, level: info}
   #- {type: file, path: verdaccio.log, level: info}
 

+ 6 - 2
packages/create/src/create-vendure-app.ts

@@ -106,10 +106,14 @@ async function createApp(
                         path.join(root, 'package.json'),
                         JSON.stringify(packageJsonContents, null, 2) + os.EOL,
                     );
-                    const { dependencies, devDependencies } = getDependencies(usingTs, dbType);
+                    const { dependencies, devDependencies } = getDependencies(
+                        usingTs,
+                        dbType,
+                        isCi ? `@${packageJson.version}` : '',
+                    );
 
                     subscriber.next(`Installing ${dependencies.join(', ')}`);
-                    installPackages(root, useYarn, dependencies, false, logLevel)
+                    installPackages(root, useYarn, dependencies, false, logLevel, isCi)
                         .then(() => {
                             if (devDependencies.length) {
                                 subscriber.next(`Installing ${devDependencies.join(', ')}`);

+ 14 - 4
packages/create/src/helpers.ts

@@ -165,6 +165,7 @@ export function installPackages(
     dependencies: string[],
     isDev: boolean,
     logLevel: CliLogLevel,
+    isCi: boolean = false,
 ): Promise<void> {
     return new Promise((resolve, reject) => {
         let command: string;
@@ -175,6 +176,14 @@ export function installPackages(
             if (isDev) {
                 args.push('--dev');
             }
+            if (isCi) {
+                // In CI, publish to Verdaccio
+                // See https://github.com/yarnpkg/yarn/issues/6029
+                args.push('--registry http://localhost:4873/');
+                // Increase network timeout
+                // See https://github.com/yarnpkg/yarn/issues/4890#issuecomment-358179301
+                args.push('--network-timeout 300000');
+            }
             args = args.concat(dependencies);
 
             // Explicitly set cwd() to work around issues like
@@ -214,12 +223,13 @@ export function installPackages(
 export function getDependencies(
     usingTs: boolean,
     dbType: DbType,
+    vendurePkgVersion = '',
 ): { dependencies: string[]; devDependencies: string[] } {
     const dependencies = [
-        '@vendure/core',
-        '@vendure/email-plugin',
-        '@vendure/asset-server-plugin',
-        '@vendure/admin-ui-plugin',
+        `@vendure/core${vendurePkgVersion}`,
+        `@vendure/email-plugin${vendurePkgVersion}`,
+        `@vendure/asset-server-plugin${vendurePkgVersion}`,
+        `@vendure/admin-ui-plugin${vendurePkgVersion}`,
         dbDriverPackage(dbType),
     ];
     const devDependencies = ['concurrently'];