diff options
author | Evan Read <eread@gitlab.com> | 2022-05-20 09:47:58 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2022-05-20 09:47:58 +0300 |
commit | bcb669cd6a50677a7b00d51cb3f2d707e6b0f462 (patch) | |
tree | a0b76557f4fded688d58c96075d9b761a2695b50 | |
parent | 6c9df20fbc0d60904b62dea6c2886d0a8e494218 (diff) |
Refactor testing page and add link checking documentation
-rw-r--r-- | .gitlab-ci.yml | 6 | ||||
-rw-r--r-- | .yamllint | 4 | ||||
-rw-r--r-- | Brewfile | 1 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | doc/testing.md | 90 |
5 files changed, 70 insertions, 33 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3c7bfe4f..5ba30e66 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ default: - ruby -v - gem -v - bundle -v - - bundle config set --local deployment true # Install dependencies into ./vendor/ruby + - bundle config set --local deployment true # Install dependencies into ./vendor/ruby - NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install --jobs 4 .yarn: @@ -382,7 +382,7 @@ test_EOL_whitespace: script: - yarn global add markdownlint-cli@$MARKDOWNLINT_VERSION - apk add jq - - bundle config set --local deployment true # Install dependencies into ./vendor/ruby + - bundle config set --local deployment true # Install dependencies into ./vendor/ruby - bundle install - bundle exec rake setup_git default - markdownlint --config tasks/whitespace_task.yml '../gitlab/doc/**/*.md' '../gitlab-runner/doc/**/*.md' '../omnibus-gitlab/doc/**/*.md' '../charts-gitlab/doc/**/*.md' @@ -398,7 +398,7 @@ test_unlinked_images: dependencies: [] script: - apk add jq - - bundle config set --local deployment true # Install dependencies into ./vendor/ruby + - bundle config set --local deployment true # Install dependencies into ./vendor/ruby - bundle install - bundle exec rake setup_git default - cp tasks/unlinked-images.sh ../gitlab/unlinked-images.sh @@ -3,5 +3,7 @@ extends: default rules: - line-length: disable + comments-indentation: + ignore: content/_data/navigation.yaml document-start: disable + line-length: disable @@ -1 +1,2 @@ brew "hadolint" +brew "yamllint" @@ -97,4 +97,4 @@ brew-bundle: test: setup brew-bundle @printf "\n$(INFO)INFO: Running all tests..$(INFO_END)\n" - @bundle exec rspec && yarn test && yarn eslint && yarn prettier && hadolint latest.Dockerfile .gitpod.Dockerfile **/*.Dockerfile + @bundle exec rspec && yarn test && yarn eslint && yarn prettier && hadolint latest.Dockerfile .gitpod.Dockerfile **/*.Dockerfile && yamllint .gitlab-ci.yml content/_data diff --git a/doc/testing.md b/doc/testing.md index bb0e5497..e0ee93aa 100644 --- a/doc/testing.md +++ b/doc/testing.md @@ -1,41 +1,75 @@ -# Testing the GitLab docs site +# Testing the GitLab Docs site -Before any changes to the `gitlab-docs` project are merged, they are tested in a merge request's -CI/CD pipeline. The pipeline configuration is in the [`.gitlab-ci.yml`](../.gitlab-ci.yml) file. +Tests for the GitLab Docs site include tests for code and tests for links in content. For more information, see +[Documentation testing](https://docs.gitlab.com/ee/development/documentation/testing.html). -You can [run the same tests locally](#run-tests-locally), before pushing your changes -to the project. +Tests are run in `gitlab-docs` [CI/CD pipeline](https://gitlab.com/gitlab-org/gitlab-docs/-/pipelines), which is +configured in the project's [`.gitlab-ci.yml`](../.gitlab-ci.yml) file. -## What do we test? +## Code tests -| Test target | Tool | Purpose | -| ------------ | ----------- | ------------------- | -| CSS | Stylelint | Code quality | -| Dockerfiles | Hadolint | Syntax checks | -| JavaScript | ESLint | Syntax checks | -| JavaScript | Prettier | Code formatting | -| Links | Nanoc check | Find broken links | -| Ruby | RSpec | Unit tests | -| Vue | Jest | Unit tests | -| YAML | yamllint | Syntax checks | +These code tests are included in the project: -## Run tests locally +| Test target | Tool | Purpose | +|:------------|:------------|:------------------| +| CSS | Stylelint | Code quality | +| Dockerfiles | Hadolint | Syntax checks | +| JavaScript | ESLint | Syntax checks | +| JavaScript | Prettier | Code formatting | +| Ruby | RSpec | Unit tests | +| Vue | Jest | Unit tests | +| YAML | yamllint | Syntax checks | -You must install the dependencies before you can run tests locally: +Stylelint tests are run in the CI/CD pipeline only. -- node modules: `yarn install` -- Ruby gems: `bundle install` -- hadolint (MacOS: `brew install hadolint`) -- yamllint (MacOS: `brew install yamllint`) +### Run code tests locally To run the tests: -`make test` +```shell +make test +``` -### Lefthook +### Install Lefthook -Optionally, you can use Lefthook to automatically run tests before pushing code. -Install Lefthook with `lefthook install`, then the tests run each time you run a -`git push` command +If you want to run the tests before pushing changes, use [Lefthook](https://github.com/evilmartians/lefthook#readme). +To install Lefthook, run: -Lefthook settings are configured in [`lefthook.yml`](../lefthook.yml). +```shell +lefthook install +``` + +Tests are run whenever you run `git push`. + +Lefthook is configured in [`lefthook.yml`](../lefthook.yml). + +## Link tests + +You can use `gitlab-docs` to test links in content. These tests don't test `gitlab-docs`, but the content in the +projects that comprise the published GitLab Docs site. + +### Run link tests locally + +To test links between content pages, run: + +```shell +make internal-links-check +``` + +To test anchor links, run: + +```shell +make internal-anchors-check +``` + +To test both links between content pages and anchor links, run: + +```shell +make internal-links-and-anchors-check +``` + +To test external links, run: + +```shell +make external-links-check +``` |