From 1fd2272000ac6defd9ee1c9be7b3eb982869ff14 Mon Sep 17 00:00:00 2001 From: Karl von Randow Date: Tue, 2 Jul 2024 15:16:20 +1200 Subject: [PATCH] ci: fix build --- .github/workflows/github-actions-build.yml | 35 +++++++++++----------- jest.config.js | 1 + src/__tests__/compile.spec.ts | 11 ++++++- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/.github/workflows/github-actions-build.yml b/.github/workflows/github-actions-build.yml index 0b19969..f6038a4 100644 --- a/.github/workflows/github-actions-build.yml +++ b/.github/workflows/github-actions-build.yml @@ -6,29 +6,28 @@ jobs: strategy: matrix: node-version: - - 12.x - - 14.x - - 16.x + - 18.x + - 20.x steps: - name: Check out repository code - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v2 + uses: actions/checkout@v4 + - name: Check out test specs + uses: actions/checkout@v4 with: - java-version: '11' - distribution: 'adopt' - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node-version }} + repository: 'karlvr/openapi-generator-plus-generators' + path: 'test-input' # https://pnpm.io/continuous-integration - - name: Cache .pnpm-store - uses: actions/cache@v1 + - uses: pnpm/action-setup@v3 + with: + version: 9 + - uses: actions/setup-node@v4 with: - path: ~/.pnpm-store - key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} - - name: Install pnpm - run: curl -f https://get.pnpm.io/v6.14.js | node - add --global pnpm@6 + node-version: 20 + cache: 'pnpm' - run: pnpm install - run: pnpm build + - name: Use Node.js ${{ matrix.node-version }} for test + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} - run: pnpm test diff --git a/jest.config.js b/jest.config.js index 8d373e8..da0d285 100644 --- a/jest.config.js +++ b/jest.config.js @@ -6,6 +6,7 @@ module.exports = { '/node_modules/', '/dist/', '/test-output/', + '/test-input/', ], /* Only run files with test or spec in their filename, so we can have support files in __tests__ */ testRegex: '(\\.|/)(test|spec)\\.[jt]sx?$', diff --git a/src/__tests__/compile.spec.ts b/src/__tests__/compile.spec.ts index 3bddd8e..dffa71b 100644 --- a/src/__tests__/compile.spec.ts +++ b/src/__tests__/compile.spec.ts @@ -21,10 +21,19 @@ describe('compile test cases', () => { } const basePath = path.join(__dirname, '..', '..', '__tests__', 'specs') - compileFiles(basePath, fs.readdirSync(basePath)) + if (fs.existsSync(basePath)) { + compileFiles(basePath, fs.readdirSync(basePath)) + } else { + console.warn(`Cannot find __tests__ in local repo: ${basePath}`) + } const sharedBasePath = path.join(__dirname, '../../../openapi-generator-plus-generators/__tests__/specs') if (fs.existsSync(sharedBasePath)) { compileFiles(sharedBasePath, fs.readdirSync(sharedBasePath)) } + + const ciSharedBasePath = path.join(__dirname, '../../test-input/__tests__/specs') + if (fs.existsSync(ciSharedBasePath)) { + compileFiles(ciSharedBasePath, fs.readdirSync(ciSharedBasePath)) + } })