Commit ca51de93 authored by drew cimino's avatar drew cimino

Specify that disabled templates are not valid in FOSS

Apply suggestions to accessibility_testing.md
parent f6324606
--- ---
title: Initial a11y scanning CI template title: Add accessibility scanning CI template
merge_request: 25144 merge_request: 25144
author: author:
type: added type: added
...@@ -4,7 +4,7 @@ type: reference, howto ...@@ -4,7 +4,7 @@ type: reference, howto
# Accessibility Testing # Accessibility Testing
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/25144) in [GitLab Core](https://about.gitlab.com/pricing/) 12.8. > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/25144) in GitLab 12.8.
If your application offers a web interface and you are using If your application offers a web interface and you are using
[GitLab CI/CD](../../../ci/README.md), you can quickly determine the accessibility [GitLab CI/CD](../../../ci/README.md), you can quickly determine the accessibility
...@@ -14,25 +14,22 @@ impact of pending code changes. ...@@ -14,25 +14,22 @@ impact of pending code changes.
GitLab uses [pa11y](https://pa11y.org/), a free and open source tool for GitLab uses [pa11y](https://pa11y.org/), a free and open source tool for
measuring the accessibility of web sites, and has built a simple measuring the accessibility of web sites, and has built a simple
[CI template](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Verify/Accessibility.gitlab-ci.yml) [CI job template](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Verify/Accessibility.gitlab-ci.yml).
which outputs the results in a file called `accessibility`. This outputs This job outputs accessibility violations, warnings, and notices for each page
the accessibility violations, warnings, and notices for each page that is analyzed. analyzed to a file called `accessibility`.
## Configuring Accessiblity Testing ## Configure Accessibility Testing
This example shows how to run [pa11y](https://pa11y.org/) This example shows how to run [pa11y](https://pa11y.org/)
on your code by using GitLab CI/CD with a plain node Docker image. on your code with GitLab CI/CD using a node Docker image.
For GitLab 12.8 and later, to define the `performance` job, you must For GitLab 12.8 and later, to define the `a11y` job, you must
[include](../../../ci/yaml/README.md#includetemplate) the [include](../../../ci/yaml/README.md#includetemplate) the
[`Accessibility.gitlab-ci.yml` template](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Verify/Accessibility.gitlab-ci.yml) [`Accessibility.gitlab-ci.yml` template](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Verify/Accessibility.gitlab-ci.yml)
that's provided as a part of your GitLab installation. included with your GitLab installation, as shown below.
For GitLab versions earlier than 12.8, you can copy and use the job as For GitLab versions earlier than 12.8, you can copy and use the job as
defined in that template. defined in that template.
CAUTION: **Caution:**
The job definition provided by the template does not support Kubernetes yet.
Add the following to your `.gitlab-ci.yml` file: Add the following to your `.gitlab-ci.yml` file:
```yaml ```yaml
...@@ -44,10 +41,13 @@ a11y: ...@@ -44,10 +41,13 @@ a11y:
a11y_urls: https://example.com https://example.com/another-page a11y_urls: https://example.com https://example.com/another-page
``` ```
The above example will create a `a11y` job in your CI/CD pipeline and will run The example above will create an `a11y` job in your CI/CD pipeline and will run
Pa11y against the webpage you defined in `a11y_urls` to build a report. Pa11y against the webpage you defined in `a11y_urls` to build a report.
The full HTML Pa11y report will be saved as an artifact that can be viewed directly in your browser. The full HTML Pa11y report will be saved as an artifact that can be [viewed directly in your browser](../pipelines/job_artifacts.md#browsing-artifacts).
NOTE: **Note:**
The job definition provided by the template does not support Kubernetes yet.
It is not yet possible to pass configurations into Pa11y via CI configuration. To change anything, It is not yet possible to pass configurations into Pa11y via CI configuration. To change anything,
copy the template to your CI file and make the desired edits. copy the template to your CI file and make the desired edits.
...@@ -91,6 +91,7 @@ or link to useful information directly in the merge request page: ...@@ -91,6 +91,7 @@ or link to useful information directly in the merge request page:
| Feature | Description | | Feature | Description |
|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Accessibility Testing](accessibility_testing.md) | Automatically report A11y violations for changed pages in merge requests |
| [Browser Performance Testing](browser_performance_testing.md) **(PREMIUM)** | Quickly determine the performance impact of pending code changes. | | [Browser Performance Testing](browser_performance_testing.md) **(PREMIUM)** | Quickly determine the performance impact of pending code changes. |
| [Code Quality](code_quality.md) **(STARTER)** | Analyze your source code quality using the [Code Climate](https://codeclimate.com/) analyzer and show the Code Climate report right in the merge request widget area. | | [Code Quality](code_quality.md) **(STARTER)** | Analyze your source code quality using the [Code Climate](https://codeclimate.com/) analyzer and show the Code Climate report right in the merge request widget area. |
| [Display arbitrary job artifacts](../../../ci/yaml/README.md#artifactsexpose_as) | Configure CI pipelines with the `artifacts:expose_as` parameter to directly link to selected [artifacts](../pipelines/job_artifacts.md) in merge requests. | | [Display arbitrary job artifacts](../../../ci/yaml/README.md#artifactsexpose_as) | Configure CI pipelines with the `artifacts:expose_as` parameter to directly link to selected [artifacts](../pipelines/job_artifacts.md) in merge requests. |
......
# frozen_string_literal: true
require 'spec_helper'
describe "CI YML Templates" do
using RSpec::Parameterized::TableSyntax
subject { Gitlab::Ci::YamlProcessor.new(content) }
where(:template_name) do
Gitlab::Template::GitlabCiYmlTemplate.all.map(&:full_name)
end
with_them do
let(:content) do
<<~EOS
include:
- template: #{template_name}
concrete_build_implemented_by_a_user:
stage: test
script: do something
EOS
end
it 'is valid' do
expect { subject }.not_to raise_error
end
it 'require default stages to be included' do
expect(subject.stages).to include(*Gitlab::Ci::Config::Entry::Stages.default)
end
end
end
...@@ -5,7 +5,7 @@ module Gitlab ...@@ -5,7 +5,7 @@ module Gitlab
module Template module Template
module Finders module Finders
class GlobalTemplateFinder < BaseTemplateFinder class GlobalTemplateFinder < BaseTemplateFinder
def initialize(base_dir, extension, categories = {}, exclusions = []) def initialize(base_dir, extension, categories = {}, exclusions: [])
@categories = categories @categories = categories
@extension = extension @extension = extension
@exclusions = exclusions @exclusions = exclusions
......
...@@ -34,7 +34,7 @@ module Gitlab ...@@ -34,7 +34,7 @@ module Gitlab
def finder(project = nil) def finder(project = nil)
Gitlab::Template::Finders::GlobalTemplateFinder.new( Gitlab::Template::Finders::GlobalTemplateFinder.new(
self.base_dir, self.extension, self.categories, self.disabled_templates self.base_dir, self.extension, self.categories, exclusions: self.disabled_templates
) )
end end
end end
......
...@@ -2,33 +2,43 @@ ...@@ -2,33 +2,43 @@
require 'spec_helper' require 'spec_helper'
describe "CI YML Templates" do describe 'CI YML Templates' do
using RSpec::Parameterized::TableSyntax
subject { Gitlab::Ci::YamlProcessor.new(content) } subject { Gitlab::Ci::YamlProcessor.new(content) }
where(:template_name) do let(:all_templates) { Gitlab::Template::GitlabCiYmlTemplate.all.map(&:full_name) }
Gitlab::Template::GitlabCiYmlTemplate.all.map(&:full_name)
end
with_them do
let(:content) do
<<~EOS
include:
- template: #{template_name}
concrete_build_implemented_by_a_user: let(:disabled_templates) do
stage: test Gitlab::Template::GitlabCiYmlTemplate.disabled_templates.map do |template|
script: do something template + Gitlab::Template::GitlabCiYmlTemplate.extension
EOS
end end
end
context 'included in a CI YAML configuration' do
using RSpec::Parameterized::TableSyntax
it 'is valid' do where(:template_name) do
expect { subject }.not_to raise_error all_templates - disabled_templates
end end
it 'require default stages to be included' do with_them do
expect(subject.stages).to include(*Gitlab::Ci::Config::Entry::Stages.default) let(:content) do
<<~EOS
include:
- template: #{template_name}
concrete_build_implemented_by_a_user:
stage: test
script: do something
EOS
end
it 'is valid' do
expect { subject }.not_to raise_error
end
it 'require default stages to be included' do
expect(subject.stages).to include(*Gitlab::Ci::Config::Entry::Stages.default)
end
end end
end end
end end
...@@ -15,7 +15,7 @@ describe Gitlab::Template::Finders::GlobalTemplateFinder do ...@@ -15,7 +15,7 @@ describe Gitlab::Template::Finders::GlobalTemplateFinder do
FileUtils.rm_rf(base_dir) FileUtils.rm_rf(base_dir)
end end
subject(:finder) { described_class.new(base_dir, '', { 'General' => '', 'Bar' => 'Bar' }, exclusions) } subject(:finder) { described_class.new(base_dir, '', { 'General' => '', 'Bar' => 'Bar' }, exclusions: exclusions) }
let(:exclusions) { [] } let(:exclusions) { [] }
...@@ -29,7 +29,7 @@ describe Gitlab::Template::Finders::GlobalTemplateFinder do ...@@ -29,7 +29,7 @@ describe Gitlab::Template::Finders::GlobalTemplateFinder do
expect(finder.find('test-template')).to be_present expect(finder.find('test-template')).to be_present
end end
it 'it does not find a prefixed template' do it 'does not find a prefixed template' do
expect(finder.find('Bar/test-template')).to be_nil expect(finder.find('Bar/test-template')).to be_nil
end end
...@@ -67,7 +67,8 @@ describe Gitlab::Template::Finders::GlobalTemplateFinder do ...@@ -67,7 +67,8 @@ describe Gitlab::Template::Finders::GlobalTemplateFinder do
end end
# NOTE: This spec fails, the template Bar/test-template is found # NOTE: This spec fails, the template Bar/test-template is found
xit 'it does not find the template without a prefix' do # See Gitlab issue: https://gitlab.com/gitlab-org/gitlab/issues/205719
xit 'does not find the template without a prefix' do
expect(finder.find('test-template')).to be_nil expect(finder.find('test-template')).to be_nil
end end
...@@ -83,6 +84,7 @@ describe Gitlab::Template::Finders::GlobalTemplateFinder do ...@@ -83,6 +84,7 @@ describe Gitlab::Template::Finders::GlobalTemplateFinder do
end end
# NOTE: This spec fails, the template Bar/test-template is found # NOTE: This spec fails, the template Bar/test-template is found
# See Gitlab issue: https://gitlab.com/gitlab-org/gitlab/issues/205719
xit 'does not find the template without a prefix' do xit 'does not find the template without a prefix' do
expect(finder.find('test-template')).to be_nil expect(finder.find('test-template')).to be_nil
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment