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

repo sync #83

Merged
merged 4 commits into from
Sep 30, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/help/repository/code-scanning-alert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/help/repository/code-scanning-click-alert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/help/repository/code-scanning-pr-alert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/help/repository/code-scanning-show-paths.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Automatically scanning your code for vulnerabilities and errors
shortTitle: Scanning automatically
intro: 'You can find vulnerabilities and errors in your project''s code on {% data variables.product.prodname_dotcom %}, as well as view, triage, understand, and resolve the related {% data variables.product.prodname_code_scanning %} alerts.'
mapTopic: true
product: '{% data reusables.gated-features.code-scanning %}'
versions:
free-pro-team: '*'
enterprise-server: '>=2.22'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ versions:
enterprise-server: '>=2.22'
---

{% data reusables.code-scanning.beta-codeql-runner %}
{% data reusables.code-scanning.beta %}
{% data reusables.code-scanning.enterprise-enable-code-scanning %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Finding security vulnerabilities and errors in your code
product: '{% data reusables.gated-features.code-scanning %}'
redirect_from:
- /github/managing-security-vulnerabilities/finding-security-vulnerabilities-in-your-projects-code
versions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Integrating with code scanning
shortTitle: Integration
intro: 'You can integrate {% data variables.product.prodname_codeql %} {% data variables.product.prodname_code_scanning %} with your existing CI systems or upload results from other tools.'
mapTopic: true
product: '{% data reusables.gated-features.code-scanning %}'
redirect_from:
- /github/finding-security-vulnerabilities-and-errors-in-your-code/managing-results-from-code-scanning
versions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ redirect_from:
---

{% data reusables.code-scanning.beta %}
{% data reusables.code-scanning.enterprise-enable-code-scanning %}

### About alerts from {% data variables.product.prodname_code_scanning %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ versions:
enterprise-server: '>=2.22'
---

{% data reusables.code-scanning.beta-codeql-runner %}
{% data reusables.code-scanning.beta %}
{% data reusables.code-scanning.enterprise-enable-code-scanning %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ versions:
---

{% data reusables.code-scanning.beta %}
{% data reusables.code-scanning.enterprise-enable-code-scanning %}

### About SARIF support

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ versions:
---

{% data reusables.code-scanning.beta %}
{% data reusables.code-scanning.enterprise-enable-code-scanning-actions %}

### About {% data variables.product.prodname_code_scanning %} results on pull requests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ versions:
enterprise-server: '>=2.22'
---

{% data reusables.code-scanning.beta-codeql-runner %}
{% data reusables.code-scanning.beta %}
{% data reusables.code-scanning.enterprise-enable-code-scanning %}

### The `init` command takes too long

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ versions:
---

{% data reusables.code-scanning.beta %}
{% data reusables.code-scanning.enterprise-enable-code-scanning-actions %}

### Automatic build for a compiled language fails

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ For more information about hosting your own instance of [{% data variables.produ

- {% data variables.contact.github_support %} {% data variables.product.premium_plus_support_plan %}
- {% data variables.product.prodname_insights %}
- {% data variables.product.prodname_advanced_security %}
- {% data variables.product.prodname_advanced_security %}{% if currentVersion == "free-pro-team@latest" %}. For more information, see "[About {% data variables.product.prodname_code_scanning %}](/github/finding-security-vulnerabilities-and-errors-in-your-code/about-code-scanning)" and "[About {% data variables.product.prodname_secret_scanning %}](/github/administering-a-repository/about-secret-scanning) (beta)."{% elsif currentVersion ver_gt "enterprise-server@2.21" %}. For more information, see "[About {% data variables.product.prodname_code_scanning %}](/github/finding-security-vulnerabilities-and-errors-in-your-code/about-code-scanning) (beta)."{% endif %}
- [{% data variables.product.prodname_learning %} for organizations](https://lab.github.com/organizations)

For more information about signing up for {% data variables.product.prodname_ghe_one %}, contact [{% data variables.product.product_name %}'s Sales team](https://enterprise.github.com/contact).
9 changes: 9 additions & 0 deletions data/reusables/code-scanning/beta-codeql-runner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% if currentVersion == "free-pro-team@latest" %}

{% note %}

**Note:** The {% data variables.product.prodname_codeql_runner %} is currently in beta and subject to change.

{% endnote %}

{% endif %}
6 changes: 5 additions & 1 deletion data/reusables/code-scanning/beta.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{% if currentVersion == "enterprise-server@2.22" %}

{% note %}

**Note:** {% data variables.product.prodname_code_scanning_capc %} is currently in beta and subject to change. {% if currentVersion == "free-pro-team@latest" %}To request access to the beta, [join the waitlist](https://github.com/features/security/advanced-security/signup).{% else %}If your organization has an {% data variables.product.prodname_advanced_security %} license, you can [join the beta program](https://resources.github.com/beta-signup/).{% endif %}
**Note:** {% data variables.product.prodname_code_scanning_capc %} is currently in beta and subject to change. For more information about taking part in the beta, [sign up here](https://resources.github.com/beta-signup/).

{% endnote %}

{% endif %}
1 change: 1 addition & 0 deletions data/reusables/gated-features/code-scanning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% data variables.product.prodname_code_scanning_capc %} is available in public repositories, and in public and private repositories owned by organizations with a license for {% data variables.product.prodname_advanced_security %}. {% if currentVersion == "free-pro-team@latest" %}{% data reusables.gated-features.more-info %}{% endif %}
55 changes: 30 additions & 25 deletions javascripts/search.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const instantsearch = require('instantsearch.js').default
const { searchBox, hits } = require('instantsearch.js/es/widgets')
const { searchBox, hits, configure } = require('instantsearch.js/es/widgets')
const algoliasearch = require('algoliasearch')
const searchWithYourKeyboard = require('search-with-your-keyboard')
const querystring = require('querystring')
Expand Down Expand Up @@ -131,34 +131,39 @@ export default function () {

const search = instantsearch(opts)

search.addWidget(
hits({
container: '#search-results-container',
templates: {
empty: 'No results',
item: resultTemplate
},
// useful for debugging template context, if needed
transformItems: items => {
// console.log(`transformItems`, items)
return items
}
})
)

// Find search placeholder text in a <meta> tag, falling back to a default
const placeholderMeta = document.querySelector('meta[name="site.data.ui.search.placeholder"]')
const placeholder = placeholderMeta ? placeholderMeta.content : 'Search topics, products...'

search.addWidget(
searchBox({
container: '#search-input-container',
placeholder,
// only autofocus on the homepage, and only if no #hash is present in the URL
autofocus: (hasStandaloneSearch()) && !window.location.hash.length,
showReset: false,
showSubmit: false
})
search.addWidgets(
[
hits({
container: '#search-results-container',
templates: {
empty: 'No results',
item: resultTemplate
},
// useful for debugging template context, if needed
transformItems: items => {
// console.log(`transformItems`, items)
return items
}
}),
configure({
analyticsTags: [
'site:docs.github.com',
`env:${process.env.NODE_ENV}`
]
}),
searchBox({
container: '#search-input-container',
placeholder,
// only autofocus on the homepage, and only if no #hash is present in the URL
autofocus: (hasStandaloneSearch()) && !window.location.hash.length,
showReset: false,
showSubmit: false
})
]
)

// enable for debugging
Expand Down
94 changes: 18 additions & 76 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
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"html-entities": "^1.2.1",
"html-truncate": "^1.2.2",
"imurmurhash": "^0.1.4",
"instantsearch.js": "^3.6.0",
"instantsearch.js": "^4.8.2",
"is-url": "^1.2.4",
"js-cookie": "^2.2.1",
"js-yaml": "^3.14.0",
Expand Down
26 changes: 25 additions & 1 deletion tests/browser/browser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* global page */
/* global page, browser */
const sleep = require('await-sleep')
const querystring = require('querystring')

describe('homepage', () => {
test('should be titled "GitHub Documentation"', async () => {
Expand Down Expand Up @@ -36,6 +37,29 @@ describe('algolia browser search', () => {
expect(hits.length).toBeGreaterThan(5)
})

it('sends the correct data to algolia', async () => {
const newPage = await browser.newPage()
await newPage.goto('http://localhost:4001/ja/enterprise/2.22/admin/installation')

await newPage.setRequestInterception(true)
newPage.on('request', interceptedRequest => {
if (interceptedRequest.method() === 'POST' && /algolia/i.test(interceptedRequest.url())) {
const data = JSON.parse(interceptedRequest.postData())
const { indexName, params } = data.requests[0]
const parsedParams = querystring.parse(params)
const analyticsTags = JSON.parse(parsedParams.analyticsTags)
expect(indexName).toBe('github-docs-2.22-ja')
expect(analyticsTags).toHaveLength(2)
// browser tests are run against production build, so we are expecting env:production
expect(analyticsTags).toEqual(expect.arrayContaining(['site:docs.github.com', 'env:production']))
}
interceptedRequest.continue()
})

await newPage.click('#search-input-container input[type="search"]')
await newPage.type('#search-input-container input[type="search"]', 'test')
})

it('removes `algolia-query` query param after page load', async () => {
await page.goto('http://localhost:4001/en?algolia-query=helpme')

Expand Down
4 changes: 3 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const { EnvironmentPlugin } = require('webpack')

module.exports = {
entry: './javascripts/index.js',
Expand Down Expand Up @@ -67,6 +68,7 @@ module.exports = {
patterns: [
{ from: 'node_modules/@primer/css/fonts', to: 'fonts' }
]
})
}),
new EnvironmentPlugin(['NODE_ENV'])
]
}