Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite repo-build-web in Python #266

Merged
merged 3 commits into from
Jan 30, 2021
Merged
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
1 change: 0 additions & 1 deletion .github/workflows/stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
- name: Build packages
run: |
make repo FLAGS='--remote-repo ${{ secrets.REMOTE_HTTP }}/stable'
./scripts/repo-build-web package build/repo
- name: Sync packages with the remote repository
uses: ./.github/actions/sync-repository
with:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
- name: Build packages
run: |
make repo FLAGS='--remote-repo ${{ secrets.REMOTE_HTTP }}/testing'
./scripts/repo-build-web package build/repo
- name: Sync packages with the remote repository
uses: ./.github/actions/sync-repository
with:
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ click==7.1.2
docker==4.4.1
idna==2.10
isort==5.7.0
Jinja2==2.11.2
lazy-object-proxy==1.4.3
MarkupSafe==1.1.1
mccabe==0.6.1
mypy==0.790
mypy-extensions==0.4.3
Expand Down
252 changes: 0 additions & 252 deletions scripts/repo-build-web

This file was deleted.

1 change: 1 addition & 0 deletions scripts/repo_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@
builder.make(recipe_name, packages)

repo.make_index()
repo.make_listing()
26 changes: 25 additions & 1 deletion scripts/toltec/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

from datetime import datetime
import gzip
import itertools
import logging
import os
from typing import Dict, List, Optional
import requests
from .recipe import Recipe
from .util import file_sha256, HTTP_DATE_FORMAT
from . import paths
from . import paths, templating

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -110,3 +111,26 @@ def make_index(self) -> None:

index_file.write(control)
index_gzip_file.write(control)

def make_listing(self) -> None:
"""Generate the static web listing for packages in the repo."""
logger.info("Generating web listing")

by_section = lambda package: package.section
packages = [
package
for recipe in self.recipes.values()
for package in recipe.packages.values()
]
sections = dict(
(section, list(group))
for section, group in itertools.groupby(
sorted(packages, key=by_section), key=by_section
)
)

listing_path = os.path.join(paths.REPO_DIR, "index.html")
template = templating.env.get_template("listing.html")

with open(listing_path, "w") as listing_file:
listing_file.write(template.render(sections=sections))
Loading