Skip to content

Commit

Permalink
feat: windowsCI (#30)
Browse files Browse the repository at this point in the history
allow for disabling of windows testing in ci.yml
  • Loading branch information
wraithgar committed Jan 11, 2022
1 parent 82a11b5 commit 38cf7b4
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
48 changes: 48 additions & 0 deletions lib/content/ci-no-windows.yml
@@ -0,0 +1,48 @@
# This file is automatically added by @npmcli/template-oss. Do not edit.

name: CI

on:
pull_request:
push:
branches:
- main
- latest
schedule:
# "At 02:00 on Monday" https://crontab.guru/#0_1_*_*_1
- cron: "0 2 * * 1"

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- run: npm i --prefer-online -g npm@latest
- run: npm i
- run: npm run lint

test:
strategy:
fail-fast: false
matrix:
node-version: [12.13.0, 12.x, 14.15.0, 14.x, 16.13.0, 16.x]
platform:
- os: ubuntu-latest
shell: bash
- os: macos-latest
shell: bash
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm i --prefer-online -g npm@latest
- run: npm i
- run: npm test --ignore-scripts
9 changes: 8 additions & 1 deletion lib/postinstall/copy-content.js
Expand Up @@ -38,6 +38,7 @@ const defaultConfig = {
applyRootRepoFiles: true,
applyWorkspaceRepoFiles: true,
applyRootModuleFiles: true,
windowsCI: true,
}

const copyFiles = async (targetDir, files) => {
Expand Down Expand Up @@ -78,9 +79,15 @@ const copyContent = async (path, rootPath, config) => {
if (!isWorkspace) {
if (config.applyRootRepoFiles) {
await copyFiles(rootPath, repoFiles)
if (!config.windowsCI) {
// copyFiles already did the mkdir so we can just fs.copyFile now
await fs.copyFile(join(contentDir, 'ci-no-windows.yml'), join(rootPath, 'ci.yml'))
}
}
return
} // only workspace now
}

// only workspace now

// TODO: await copyFiles(path, workspaceFiles)
// if we ever have workspace specific files
Expand Down
17 changes: 17 additions & 0 deletions test/postinstall/copy-content.js
Expand Up @@ -225,3 +225,20 @@ t.test('handles workspaces with no root files', async (t) => {
await t.rejects(fs.stat(join(root, '.github', 'workflows', 'ci-amazinga.yml')))
await t.rejects(fs.stat(join(root, '.github', 'ISSUE_TEMPLATE', 'bug.yml')))
})

t.test('no windows ci', async (t) => {
const pkgWithNoWindowsCI = {
'package.json': JSON.stringify({
name: 'testpkg',
templateOSS: {
windowsCI: false,
},
}),
}
const root = t.testdir(pkgWithNoWindowsCI)
const config = await getConfig(root)
await copyContent(root, root, config)
const target = join(root, 'ci.yml')
const contents = await fs.readFile(target, 'utf8')
await t.notMatch(/windows/, contents, 'no windows ci')
})

0 comments on commit 38cf7b4

Please sign in to comment.