diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml index d7cb262088..dea02ea206 100644 --- a/.github/workflows/cli.yml +++ b/.github/workflows/cli.yml @@ -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 diff --git a/scripts/cli-e2e-test.js b/scripts/cli-e2e-test.js index c73e812985..c8374af0eb 100644 --- a/scripts/cli-e2e-test.js +++ b/scripts/cli-e2e-test.js @@ -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`); diff --git a/scripts/generateTempDir.js b/scripts/generateTempDir.js deleted file mode 100644 index 593c6eb74a..0000000000 --- a/scripts/generateTempDir.js +++ /dev/null @@ -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);