Skip to content

Commit

Permalink
ci: fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
karlvr committed Jul 2, 2024
1 parent 61b7c69 commit 1fd2272
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
35 changes: 17 additions & 18 deletions .github/workflows/github-actions-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?$',
Expand Down
11 changes: 10 additions & 1 deletion src/__tests__/compile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
})

0 comments on commit 1fd2272

Please sign in to comment.