github/workflows,scripts/cli-e2e-test: use runner temp dir instead of generated dir

This commit is contained in:
Patrik Oldsberg
2020-04-16 19:06:11 +02:00
parent 7a320302c1
commit e522989249
3 changed files with 14 additions and 45 deletions
+4 -9
View File
@@ -41,19 +41,14 @@ jobs:
- name: yarn install
run: yarn install --frozen-lockfile
- run: yarn build
# generate temp directory
- name: generate tempdir
id: generate_tempdir
run: echo "::set-output name=tempdir::$(node scripts/generateTempDir.js)"
# This creates a new app and plugin which pollutes the workspace, so it should be run last.
- name: verify app and plugin creation on Windows
working-directory: ${{ steps.generate_tempdir.outputs.tempdir }}
working-directory: ${{ runner.temp }}
if: runner.os == 'Windows'
run: node ${{ github.workspace }}/scripts/cli-e2e-test.js
env:
BACKSTAGE_E2E_CLI_TEST: true
- name: verify app and plugin creation on Linux
working-directory: ${{ steps.generate_tempdir.outputs.tempdir }}
working-directory: ${{ runner.temp }}
if: runner.os == 'Linux'
run: |
sudo sysctl fs.inotify.max_user_watches=524288
@@ -62,11 +57,11 @@ jobs:
BACKSTAGE_E2E_CLI_TEST: true
- name: lint newly created app and plugin
run: yarn lint:all
working-directory: ${{ steps.generate_tempdir.outputs.tempdir }}/test-app
working-directory: ${{ runner.temp }}/test-app
env:
BACKSTAGE_E2E_CLI_TEST: true
- name: test newly created app and plugin
run: yarn test:all
working-directory: ${{ steps.generate_tempdir.outputs.tempdir }}/test-app
working-directory: ${{ runner.temp }}/test-app
env:
BACKSTAGE_E2E_CLI_TEST: true
+10 -5
View File
@@ -14,6 +14,8 @@
* limitations under the License.
*/
const os = require('os');
const fs = require('fs-extra');
const { resolve: resolvePath } = require('path');
const Browser = require('zombie');
@@ -27,22 +29,25 @@ const {
const createTestApp = require('./createTestApp');
const createTestPlugin = require('./createTestPlugin');
const generateTempDir = require('./generateTempDir.js');
Browser.localhost('localhost', 3000);
async function createTempDir() {
return fs.mkdtemp(resolvePath(os.tmpdir(), 'backstage-e2e-'));
}
async function main() {
process.env.BACKSTAGE_E2E_CLI_TEST = 'true';
const tempDir = process.env.CI ? process.cwd() : await generateTempDir();
const workDir = process.env.CI ? process.cwd() : await createTempDir();
process.stdout.write(`Initial directory: ${process.cwd()}\n`);
process.chdir(tempDir);
process.stdout.write(`Temp directory: ${process.cwd()}\n`);
process.chdir(workDir);
process.stdout.write(`Working directory: ${process.cwd()}\n`);
await createTestApp();
const appDir = resolvePath(tempDir, 'test-app');
const appDir = resolvePath(workDir, 'test-app');
process.chdir(appDir);
process.stdout.write(`App directory: ${appDir}\n`);
-31
View File
@@ -1,31 +0,0 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const fs = require('fs-extra');
const os = require('os');
const { resolve: resolvePath } = require('path');
const { handleError } = require('./helpers');
async function generateTempDir() {
const tempDir = await fs.mkdtemp(resolvePath(os.tmpdir(), 'backstage-e2e-'));
process.stdout.write(tempDir);
return tempDir;
}
module.exports = generateTempDir;
process.on('unhandledRejection', handleError);
generateTempDir().catch(handleError);