Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(command-dev-trace): re-enable tests #1388

Merged
merged 1 commit into from Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Expand Up @@ -29,3 +29,4 @@ jobs:
# We set a flag so we can skip tests that access Netlify API
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
IS_FORK: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true }}
_NETLIFY_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -100,7 +100,7 @@
"find-up": "^4.1.0",
"fuzzy": "^0.1.3",
"get-port": "^5.1.0",
"gh-release-fetch": "^1.0.3",
"gh-release-fetch": "^1.1.0",
"git-repo-info": "^2.1.0",
"gitconfiglocal": "^2.1.0",
"http-proxy": "^1.18.0",
Expand Down
16 changes: 14 additions & 2 deletions src/lib/exec-fetcher.js
Expand Up @@ -15,6 +15,16 @@ const getExecName = ({ execName }) => {
return isWindows() ? `${execName}.exe` : execName
}

const getOptions = () => {
// this is used in out CI tests to avoid hitting GitHub API limit
// when calling gh-release-fetch
if (process.env._NETLIFY_GITHUB_TOKEN) {
return {
headers: { Authorization: `token ${process.env._NETLIFY_GITHUB_TOKEN}` },
}
}
}

const isExe = (mode, gid, uid) => {
if (isWindows()) {
return true
Expand All @@ -37,7 +47,8 @@ const execExist = async binPath => {
}

const isVersionOutdated = async ({ packageName, currentVersion }) => {
const outdated = await updateAvailable(getRepository({ packageName }), currentVersion)
const options = getOptions()
const outdated = await updateAvailable(getRepository({ packageName }), currentVersion, options)
return outdated
}

Expand Down Expand Up @@ -86,7 +97,8 @@ const fetchLatestVersion = async ({ packageName, execName, destination, extensio
extract: true,
}

await fetchLatest(release)
const options = getOptions()
await fetchLatest(release, options)
}

module.exports = { getExecName, shouldFetchLatestVersion, fetchLatestVersion }
2 changes: 1 addition & 1 deletion src/utils/traffic-mesh.js
Expand Up @@ -88,4 +88,4 @@ const runProcess = async ({ log, args }) => {
return { subprocess }
}

module.exports = { runProcess, startForwardProxy }
module.exports = { runProcess, startForwardProxy, installTrafficMesh }
10 changes: 8 additions & 2 deletions tests/command.dev.trace.test.js
@@ -1,8 +1,14 @@
const test = require('ava')
const { withSiteBuilder } = require('./utils/site-builder')
const { installTrafficMesh } = require('../src/utils/traffic-mesh')
const callCli = require('./utils/call-cli')

test.serial.skip('should not match redirect for empty site', async t => {
test.before(async () => {
// pre-install the traffic mesh agent so we can run the tests in parallel
await installTrafficMesh({ log: console.log })
})

test('should not match redirect for empty site', async t => {
await withSiteBuilder('empty-site', async builder => {
await builder.buildAsync()

Expand All @@ -14,7 +20,7 @@ test.serial.skip('should not match redirect for empty site', async t => {
})
})

test.serial.skip('should match redirect when url matches', async t => {
test('should match redirect when url matches', async t => {
await withSiteBuilder('site-with-redirects', async builder => {
builder.withRedirectsFile({
redirects: [{ from: '/*', to: `/index.html`, status: 200 }],
Expand Down