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
author:
type: added
......@@ -4,7 +4,7 @@ type: reference, howto
# 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
[GitLab CI/CD](../../../ci/README.md), you can quickly determine the accessibility
......@@ -14,25 +14,22 @@ impact of pending code changes.
GitLab uses [pa11y](https://pa11y.org/), a free and open source tool for
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)
which outputs the results in a file called `accessibility`. This outputs
the accessibility violations, warnings, and notices for each page that is analyzed.
[CI job template](https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Verify/Accessibility.gitlab-ci.yml).
This job outputs accessibility violations, warnings, and notices for each page
analyzed to a file called `accessibility`.
## Configuring Accessiblity Testing
## Configure Accessibility Testing
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
[`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
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:
```yaml
......@@ -44,10 +41,13 @@ a11y:
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.
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,
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:
| 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. |
| [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. |
......
# 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
module Template
module Finders
class GlobalTemplateFinder < BaseTemplateFinder
def initialize(base_dir, extension, categories = {}, exclusions = [])
def initialize(base_dir, extension, categories = {}, exclusions: [])
@categories = categories
@extension = extension
@exclusions = exclusions
......
......@@ -34,7 +34,7 @@ module Gitlab
def finder(project = nil)
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
......
......@@ -2,33 +2,43 @@
require 'spec_helper'
describe "CI YML Templates" do
using RSpec::Parameterized::TableSyntax
describe 'CI YML Templates' do
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}
let(:all_templates) { Gitlab::Template::GitlabCiYmlTemplate.all.map(&:full_name) }
concrete_build_implemented_by_a_user:
stage: test
script: do something
EOS
let(:disabled_templates) do
Gitlab::Template::GitlabCiYmlTemplate.disabled_templates.map do |template|
template + Gitlab::Template::GitlabCiYmlTemplate.extension
end
end
context 'included in a CI YAML configuration' do
using RSpec::Parameterized::TableSyntax
it 'is valid' do
expect { subject }.not_to raise_error
where(:template_name) do
all_templates - disabled_templates
end
it 'require default stages to be included' do
expect(subject.stages).to include(*Gitlab::Ci::Config::Entry::Stages.default)
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
end
......@@ -15,7 +15,7 @@ describe Gitlab::Template::Finders::GlobalTemplateFinder do
FileUtils.rm_rf(base_dir)
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) { [] }
......@@ -29,7 +29,7 @@ describe Gitlab::Template::Finders::GlobalTemplateFinder do
expect(finder.find('test-template')).to be_present
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
end
......@@ -67,7 +67,8 @@ describe Gitlab::Template::Finders::GlobalTemplateFinder do
end
# 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
end
......@@ -83,6 +84,7 @@ describe Gitlab::Template::Finders::GlobalTemplateFinder do
end
# 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
expect(finder.find('test-template')).to be_nil
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