Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v6
with:
python-version: "3.10"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
name: Test d.p.o redirects
name: Test redirects

on:
push:
paths:
- ".github/workflows/docs-redirects.yml"
- ".github/workflows/redirects.yml"
- "salt/docs/**"
- "salt/moin/**"
- "tests/docs-redirects/**"
- "tests/wiki-redirects/**"
pull_request:
paths:
- ".github/workflows/docs-redirects.yml"
- ".github/workflows/redirects.yml"
- "salt/docs/**"
- "salt/moin/**"
- "tests/docs-redirects/**"
- "tests/wiki-redirects/**"
workflow_dispatch:

permissions:
Expand All @@ -24,23 +28,30 @@ env:
FORCE_COLOR: "1"

jobs:
docs-redirects:
name: Hurl
redirects:
name: Hurl (${{ matrix.suite }})
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
suite:
- docs-redirects
- wiki-redirects

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Download Hurl ${{ env.HURL_VERSION }}
run: >
run: >
curl --no-progress-meter --location --fail
--proto '=https' --tlsv1.2
--output '/tmp/hurl.deb'
--output '/tmp/hurl.deb'
"https://github.com/Orange-OpenSource/hurl/releases/download/${{ env.HURL_VERSION }}/hurl_${{ env.HURL_VERSION }}_amd64.deb"
env:
HURL_VERSION: "5.0.1"
HURL_VERSION: "7.1.0"

- name: Install Hurl
run: sudo apt install --yes /tmp/hurl.deb

- name: Run tests
run: bash tests/docs-redirects/test.sh
run: bash tests/${{ matrix.suite }}/test.sh
4 changes: 2 additions & 2 deletions .github/workflows/server-list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Update salt-server-list.rst
run: |
wget --quiet -O docs/salt-server-list.rst https://salt-public.psf.io/salt-server-list.rst

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v8
with:
commit-message: Update docs/salt-server-list.rst
branch: salt-server-list
Expand Down
13 changes: 13 additions & 0 deletions salt/moin/configs/wiki-redirects.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file contains redirect configuration for wiki.python.org.
# It is included by ``wiki-static.conf``,
# and tested in ``tests/wiki-redirects/``.

location /moin/ {
rewrite ^/moin/(.+)$ $scheme://$host/python/$1.html permanent;
return 301 $scheme://$host/python/;
}

location / {
index index.html;
try_files $uri $uri/ =404;
}
7 changes: 3 additions & 4 deletions salt/moin/configs/wiki-static.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ server {

root /data/www/wiki-static;

location / {
index index.html;
try_files $uri $uri/ =404;
}
# The redirect config is in a separate file
# to allow automatic testing via Hurl (https://hurl.dev/)
include sites.d/wiki-redirects.conf;
}
10 changes: 10 additions & 0 deletions salt/moin/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ moin:
- file: /etc/nginx/sites.d/
- pkg: nginx

/etc/nginx/sites.d/wiki-redirects.conf:
file.managed:
- source: salt://moin/configs/wiki-redirects.conf
- user: root
- group: root
- mode: "0644"
- require:
- file: /etc/nginx/sites.d/
- pkg: nginx

/etc/consul.d/service-moin.json:
file.managed:
- source: salt://consul/etc/service.jinja
Expand Down
5 changes: 5 additions & 0 deletions tests/wiki-redirects/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
server {
listen 10001;
root /var/empty;
include wiki-redirects.conf;
}
24 changes: 24 additions & 0 deletions tests/wiki-redirects/specs/moin-redirects.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Assert that old /moin/ URLs redirect to the static archive.

GET {{host}}/moin/BeginnersGuide
HTTP 301
[Asserts]
header "Location" == "http://localhost/python/BeginnersGuide.html"

GET {{host}}/moin/PythonBooks
HTTP 301
[Asserts]
header "Location" == "http://localhost/python/PythonBooks.html"

GET {{host}}/moin/FrontPage
HTTP 301
[Asserts]
header "Location" == "http://localhost/python/FrontPage.html"


# Assert that /moin/ root redirects to /python/.

GET {{host}}/moin/
HTTP 301
[Asserts]
header "Location" == "http://localhost/python/"
19 changes: 19 additions & 0 deletions tests/wiki-redirects/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -euxo pipefail

# Test the wiki redirects. This script must be run from the repository root.

docker stop wiki-redirects-nginx || true

docker run --name wiki-redirects-nginx --detach --quiet --rm --tty \
--mount type=bind,source=./tests/wiki-redirects/nginx.conf,target=/etc/nginx/conf.d/wiki.conf,readonly \
--mount type=bind,source=./salt/moin/configs/wiki-redirects.conf,target=/etc/nginx/wiki-redirects.conf,readonly \
-p 10001:10001 \
nginx:1.26.1-alpine

# Wait for the nginx container to start…
sleep 1

hurl --color --continue-on-error --variable host=http://localhost:10001 --test ./tests/wiki-redirects/specs/*.hurl

docker stop wiki-redirects-nginx