Skip to content

Commit

Permalink
Added yaml test
Browse files Browse the repository at this point in the history
  • Loading branch information
desdic committed Feb 25, 2024
1 parent ea7f9ac commit 9f5a712
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/yaml/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3"

services:
fakelookup:
build: containers/fakelookup
ports:
- 8080:80

shell:
build: containers/shell
ports:
- 2200:2200

test-runner:
build: containers/test-runner
command: sleep 3600
volumes:
- ./:/build:ro
- ./report:/build/report:rw
68 changes: 68 additions & 0 deletions tests/yaml/github-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
name: 'Link Checker: All English'

# **What it does**: Renders the content of every page and check all internal links.
# **Why we have it**: To make sure all links connect correctly.
# **Who does it impact**: Docs content.

on:
workflow_dispatch:
push:
branches:
- main
pull_request:

permissions:
contents: read
# Needed for the 'trilom/file-changes-action' action
pull-requests: read

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
check-links:
runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16.13.x
cache: npm

- name: Install
run: npm ci

# Creates file "$/files.json", among others
- name: Gather files changed
uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b
with:
fileOutput: 'json'

# For verification
- name: Show files changed
run: cat $HOME/files.json

- name: Link check (warnings, changed files)
run: |
./script/rendered-content-link-checker.mjs \
--language en \
--max 100 \
--check-anchors \
--check-images \
--verbose \
--list $HOME/files.json
- name: Link check (critical, all files)
run: |
./script/rendered-content-link-checker.mjs \
--language en \
--exit \
--verbose \
--check-images \
--level critical
48 changes: 48 additions & 0 deletions tests/yaml_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
describe("yaml", function()
local core = require("agrolens.core")
local buffers = nil
local eq = assert.equals

it("docker-compose", function()
vim.cmd.edit("tests/yaml/docker-compose.yml")
buffers = vim.api.nvim_list_bufs()

local entries = core.get_captures({ queries = { "docker-compose" }, bufids = buffers })

eq(#entries, 3)
eq(entries[1].filename, "tests/yaml/docker-compose.yml")
eq(entries[1].lnum, 4)
eq(entries[1].col, 2)

eq(entries[1].line, " fakelookup:")
eq(entries[2].line, " shell:")
eq(entries[3].line, " test-runner:")

vim.cmd("%bdelete")
end)
end)

describe("yaml2", function()
it("github-workflow-steps", function()
local core = require("agrolens.core")
local buffers = nil
local eq = assert.equals

vim.cmd.edit("tests/yaml/github-ci.yml")
buffers = vim.api.nvim_list_bufs()

local entries = core.get_captures({ queries = { "github-workflow-steps" }, bufids = buffers })

eq(#entries, 12)
eq(entries[1].filename, "tests/yaml/github-ci.yml")
eq(entries[1].lnum, 29)
eq(entries[1].col, 20)

eq(entries[1].line, " - name: Checkout")
eq(entries[2].line, " uses: actions/checkout@v3")
eq(entries[3].line, " - name: Setup node")
eq(entries[4].line, " uses: actions/setup-node@v3")
eq(entries[5].line, " - name: Install")
eq(entries[6].line, " run: npm ci")
end)
end)

0 comments on commit 9f5a712

Please sign in to comment.