Skip to content

Commit f7697e5

Browse files
authored
Merge branch 'master' into dependabot/pip/requirements/pyyaml-5.4
2 parents 2fa4592 + 76e0cdb commit f7697e5

File tree

326 files changed

+3819
-1157
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

326 files changed

+3819
-1157
lines changed

.github/workflows/cleanup_acceptance.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ jobs:
1010
container: quay.io/hypernode/deploy:3-php8.1-node18
1111
steps:
1212
- uses: actions/checkout@v2
13+
- name: Dump env
14+
run: env
1315
- name: Cleanup acceptance environments
1416
run: hypernode-deploy cleanup acceptance -vvv
1517
env:

.github/workflows/deploy.yaml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,23 @@ jobs:
1414
runs-on: ubuntu-latest
1515
container: quay.io/hypernode/deploy:3-php8.1-node18
1616
steps:
17-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
# Declares the repository safe and not under dubious ownership.
21+
- name: Add repository to git safe directories
22+
run: git config --global --add safe.directory $GITHUB_WORKSPACE
1823
- uses: actions/cache@v2
1924
with:
2025
path: /tmp/composer-cache
2126
key: ${{ runner.os }}-composer
2227
- uses: webfactory/[email protected]
2328
with:
2429
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
25-
- run: apt update && apt install -y python3 virtualenv
30+
- name: Set env for production build
31+
if: github.ref == 'refs/heads/master'
32+
run: |
33+
echo "DOCS_BASE_URL=https://docs.hypernode.com/" >> $GITHUB_ENV
2634
- run: hypernode-deploy build -vvv
2735
- name: archive production artifacts
2836
uses: actions/upload-artifact@v3
@@ -33,6 +41,9 @@ jobs:
3341
deploy_acceptance:
3442
needs: build
3543
runs-on: ubuntu-latest
44+
environment:
45+
name: acceptance
46+
url: ${{ steps.get_brancher_hostname.outputs.BRANCHER_URL }}
3647
if: github.ref != 'refs/heads/master'
3748
container: quay.io/hypernode/deploy:3-php8.1-node18
3849
steps:
@@ -47,20 +58,24 @@ jobs:
4758
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
4859
- run: mkdir -p $HOME/.ssh
4960
- name: deploy to acceptance
50-
run: hypernode-deploy deploy acceptance -vvv
61+
run: hypernode-deploy deploy acceptance -vvv --reuse-brancher
5162
env:
5263
HYPERNODE_API_TOKEN: ${{ secrets.HYPERNODE_API_TOKEN }}
5364
- name: Get brancher hostname
54-
run: echo "BRANCHER_HOSTNAME=$(jq .hostnames[0] deployment-report.json -r)" >> $GITHUB_ENV
65+
id: get_brancher_hostname
66+
run: echo "BRANCHER_URL=https://$(jq .hostnames[0] deployment-report.json -r)" >> $GITHUB_OUTPUT
5567
- name: Comment hostname on PR
5668
uses: thollander/actions-comment-pull-request@v1
5769
with:
5870
message: |
59-
Acceptance server is available at https://${{ env.BRANCHER_HOSTNAME }}
71+
Acceptance server is available at ${{ steps.get_brancher_hostname.outputs.BRANCHER_URL }}
6072
6173
deploy_production:
6274
needs: build
6375
runs-on: ubuntu-latest
76+
environment:
77+
name: production
78+
url: https://docs.hypernode.io
6479
if: github.ref == 'refs/heads/master'
6580
container: quay.io/hypernode/deploy:3-php8.1-node18
6681
steps:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Detect renamed docs
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
detect_renamed_docs:
8+
runs-on: ubuntu-latest
9+
name: Detect renamed docs
10+
steps:
11+
- uses: actions/checkout@v3
12+
with:
13+
fetch-depth: 0
14+
- name: Get changed files
15+
id: changed_files
16+
run: |
17+
result="$(python3 ci/bin/detect_rewrites.py ${{ github.event.pull_request.base.sha }} ${{github.event.pull_request.head.sha}})"
18+
echo "$result"
19+
echo "CHANGED_FILES<<EOF" >> $GITHUB_OUTPUT
20+
echo "$result" >> $GITHUB_OUTPUT
21+
echo "EOF" >> $GITHUB_OUTPUT
22+
shell: bash
23+
- name: Comment hostname on PR
24+
if: ${{ steps.changed_files.outputs.CHANGED_FILES }}
25+
uses: thollander/actions-comment-pull-request@v1
26+
with:
27+
message: "${{ steps.changed_files.outputs.CHANGED_FILES }}"

.pre-commit-config.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: 'v4.1.0'
5+
rev: 'v4.4.0'
66
hooks:
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
99
- repo: https://github.com/psf/black
10-
rev: '22.10.0'
10+
rev: '22.12.0'
1111
hooks:
1212
- id: black
1313
- repo: https://github.com/myint/autoflake
14-
rev: 'v1.4'
14+
rev: 'v2.0.0'
1515
hooks:
1616
- id: autoflake
1717
args: ["--in-place", "--remove-unused-variables", "--remove-all-unused-imports"]
1818
- repo: https://github.com/pycqa/isort
19-
rev: '5.10.1'
19+
rev: '5.11.4'
2020
hooks:
2121
- id: isort
2222
name: isort (python)
23+
args: ["--profile", "black"]

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Hypernode
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,48 @@ Then deploy to your local Hypernode Docker:
6666
docker run --rm -it --env SSH_PRIVATE_KEY="$(cat ~/.ssh/yourdeploykey | base64)" -v ${PWD}:/build quay.io/hypernode/deploy:latest hypernode-deploy build -vvv # First build the artifact
6767
docker run --rm -it --env SSH_PRIVATE_KEY="$(cat ~/.ssh/yourdeploykey | base64)" -v ${PWD}:/build quay.io/hypernode/deploy:latest hypernode-deploy deploy docker -vvv # Then perform the deploy
6868
```
69+
70+
## Building the manpage deb
71+
72+
The docs are also packaged as a debian package named `hndocsnext` so that on a Hypernode you can run `man hypernode` (or `hypernode-manual`) and page through a `manpage` version of the Hypernode docs. To build that debian package on a Debian machine you can run these commands:
73+
```
74+
# First create the cow environment
75+
export ARCH=amd64
76+
export DIST=buster
77+
apt-get install debhelper cowbuilder git-buildpackage
78+
cowbuilder --create --distribution buster --architecture amd64 --basepath /var/cache/pbuilder/base-$DIST-amd64.cow --mirror http://ftp.debian.org/debian/ --components=main
79+
80+
# We need to make sure our build process can use networking in order to pip install the requirements
81+
echo "USENETWORK=yes" > ~/.pbuilderrc
82+
83+
# Then clone the repository and build the .deb
84+
git clone https://github.com/ByteInternet/hypernode-docs-next
85+
cd hypernode-docs-next
86+
gbp buildpackage --git-pbuilder --git-dist=$DIST --git-arch=$ARCH --git-ignore-branch -us -uc -sa --git-ignore-new
87+
```
88+
89+
Then after building the Deb you could install it with dpkg. For example:
90+
```
91+
dpkg -i ../hndocsnext_20230121.173551_all.deb
92+
```
93+
94+
And test it out with:
95+
```
96+
man hypernode
97+
```
98+
99+
To inspect the contents of the deb archive you can run:
100+
```
101+
# dpkg -L hndocsnext
102+
/.
103+
/usr
104+
/usr/local
105+
/usr/local/man
106+
/usr/local/man/man3
107+
/usr/local/man/man3/hypernode.3
108+
/usr/share
109+
/usr/share/doc
110+
/usr/share/doc/hndocsnext
111+
/usr/share/doc/hndocsnext/README.md
112+
/usr/share/doc/hndocsnext/changelog.gz
113+
```

bin/build_docs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env bash
22

3+
set -e
4+
35
pushd docs
46
make html
57
popd

bin/build_manpage

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
pushd docs
6+
make man
7+
echo "manpage located at $(realpath _build/man/docs.1)"
8+
popd

bin/find_dead_links

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env python3
2+
3+
import multiprocessing
4+
import re
5+
from glob import glob
6+
from typing import List
7+
8+
import requests
9+
10+
from hypernode.common.settings import DOCS_DIR
11+
12+
FAKE_DOMAINS = [
13+
"example.com",
14+
"yourdomain.com",
15+
"example.hypernode.io",
16+
"hypernode.local",
17+
"127.0.0.1",
18+
]
19+
20+
21+
def get_links(md_file: str) -> List[str]:
22+
with open(md_file) as f:
23+
content = f.read()
24+
return re.findall(r"\[.*\]\((http.+?)\)", content)
25+
26+
27+
def is_link_is_dead(link: str) -> bool:
28+
try:
29+
resp = requests.get(link, timeout=5)
30+
except Exception as e:
31+
print(f"Couldn't get {link}: {e}")
32+
return True
33+
dead = resp.status_code in [404, 500, 502, 503, 504]
34+
if dead:
35+
print(f"Dead link: {link}")
36+
return dead
37+
38+
39+
def main():
40+
links = []
41+
for md_file in glob(f"{DOCS_DIR}/**/*.md", recursive=True):
42+
for link in get_links(md_file):
43+
if not any(fake_domain in link for fake_domain in FAKE_DOMAINS):
44+
links.append(link)
45+
links = list(set(links))
46+
print(f"Found {len(links)} unique links")
47+
# Loop over links in a multiprocessing pool
48+
with multiprocessing.Pool(4) as p:
49+
p.map(is_link_is_dead, links)
50+
51+
52+
if __name__ == "__main__":
53+
main()

bin/generate_nginx_redirects

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env python3
2+
from hypernode.redirect.generate_nginx_redirects import main
3+
4+
if __name__ == "__main__":
5+
main()

bin/generate_redirects_from_source_links

100644100755
File mode changed.

bin/import_metadata

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env python3
2+
3+
from hypernode.metadata.importer import main
4+
5+
if __name__ == "__main__":
6+
main()

ci/bin/detect_rewrites.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import argparse
2+
import re
3+
import subprocess
4+
from typing import Tuple
5+
6+
RENAME_PATTERN = re.compile(r"^R[0-9]+")
7+
8+
9+
def parse_args() -> Tuple[str, str]:
10+
parser = argparse.ArgumentParser()
11+
parser.add_argument("start_commit")
12+
parser.add_argument("end_commit")
13+
14+
args = parser.parse_args()
15+
16+
return args.start_commit, args.end_commit
17+
18+
19+
def main():
20+
start_commit, end_commit = parse_args()
21+
diff_command = [
22+
"git",
23+
"diff",
24+
"--name-status",
25+
"-M",
26+
"--stat",
27+
start_commit,
28+
end_commit,
29+
]
30+
output = subprocess.check_output(diff_command, encoding="utf-8")
31+
renamed_files = filter(RENAME_PATTERN.match, output.splitlines())
32+
renamed_files = map(lambda x: x.split("\t")[1:], renamed_files)
33+
renamed_markdown_files = filter(lambda x: x[0].endswith(".md"), renamed_files)
34+
renamed_markdown_files = list(renamed_markdown_files)
35+
36+
if renamed_markdown_files:
37+
print("Detected renamed/moved files:")
38+
print("```")
39+
for file_from, file_to in renamed_markdown_files:
40+
print("{} => {}".format(file_from, file_to))
41+
print("```")
42+
print("To prevent 404 pages, consider adding the redirects to the new pages:")
43+
print("```markdown")
44+
print("---")
45+
print("redirect_from:")
46+
for file_from, _ in renamed_markdown_files:
47+
print(" - {}".format(file_from))
48+
print("---")
49+
print("```")
50+
51+
52+
if __name__ == "__main__":
53+
main()

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
hndocsnext (20230121.173551) UNRELEASED; urgency=medium
2+
3+
[ Rick van de Loo ]
4+
* Initial packaging
5+
6+
-- Rick van de Loo <vdloo@desktop> Sat, 21 Jan 2023 17:35:51 +0200

debian/compat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9

debian/control

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Source: hndocsnext
2+
Priority: optional
3+
Maintainer: Hypernode Tech Team <[email protected]>
4+
Build-Depends: debhelper (>= 9), python3, python3-venv, python3-dev
5+
Standards-Version: 3.9.4
6+
Homepage: https://github.com/ByteInternet/hypernode-docs-next
7+
Vcs-Git: [email protected]:ByteInternet/hypernode-docs-next.git
8+
9+
Package: hndocsnext
10+
Section: doc
11+
Architecture: all
12+
Depends: ${misc:Depends}
13+
Description: Hypernode docs in manpage form. Run 'man hypernode'.

debian/docs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
README.md

debian/hndocsnext.install

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://www.debian.org/doc/manuals/maint-guide/dother.en.html#install
2+
3+
docs/_build/man/hypernode.3 /usr/local/man/man3/

debian/hndocsnext.postinst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
set -e
3+
mandb

debian/rules

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/make -f
2+
# -*- makefile -*-
3+
4+
# Uncomment this to turn on verbose mode.
5+
#export DH_VERBOSE=1
6+
.PHONY: build
7+
8+
build:
9+
python3 -m venv venv
10+
venv/bin/pip install -r requirements/development.txt
11+
bash -c 'source venv/bin/activate; bin/build_manpage'
12+
mv docs/_build/man/docs.1 docs/_build/man/hypernode.3
13+
14+
override_dh_usrlocal:
15+
16+
%:
17+
dh $@

debian/source/format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0 (native)

0 commit comments

Comments
 (0)