Skip to content

Commit

Permalink
GitHub Actions debug (#875)
Browse files Browse the repository at this point in the history
* Test CRA: Simpler file writes

* GH Actions: Split out npm install

* Test CRA: Pipe stdio instead of inherit
  • Loading branch information
RaeesBhatti authored May 5, 2020
1 parent 55c2992 commit de9b1c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci && npm ci --prefix tests/site-cra
- run: npm ci
- run: npm ci --prefix tests/site-cra
- run: npm test
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
14 changes: 4 additions & 10 deletions tests/cra.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ const cliPath = require('./utils/cliPath')
const { randomPort } = require('./utils/')
const sitePath = path.join(__dirname, 'site-cra')

const fileOpen = util.promisify(fs.open)
const fileWriteTo = util.promisify(fs.write)
const fileClose = util.promisify(fs.close)
const fileWrite = util.promisify(fs.writeFile)

let ps, host, port

Expand All @@ -20,7 +18,7 @@ test.before(async t => {
ps = await spawn(cliPath, ['dev', '-p', randomPort()], {
cwd: sitePath,
env: { ...process.env, DUMMY_VAR: 'true', SKIP_PREFLIGHT_CHECK: 'true' },
stdio: ['inherit', 'pipe', 'inherit'],
stdio: 'pipe',
shell: true,
}
)
Expand Down Expand Up @@ -63,9 +61,7 @@ test('netlify dev cra: static file under build/', async t => {

const expectedContent = '<html><h1>Test content'

const file = await fileOpen(path.join(publicPath, 'test.html'), 'w')
await fileWriteTo(file, expectedContent)
await fileClose(file)
await fileWrite(path.join(publicPath, 'test.html'), expectedContent)

const response = await fetch(`http://${host}:${port}/test.html`)
const body = await response.text()
Expand All @@ -79,9 +75,7 @@ test('netlify dev cra: force rewrite', async t => {
const publicPath = path.join(sitePath, 'public')
await mkdirp(publicPath)

const file = await fileOpen(path.join(publicPath, 'force.html'), 'w')
await fileWriteTo(file, '<html><h1>This should never show')
await fileClose(file)
await fileWrite(path.join(publicPath, 'force.html'), '<html><h1>This should never show')

const response = await fetch(`http://${host}:${port}/force.html`)
const body = await response.text()
Expand Down

0 comments on commit de9b1c9

Please sign in to comment.