Skip to content

Commit

Permalink
Initial code and configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
bgilbert committed Jul 20, 2022
1 parent 6c10294 commit 5052ed6
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Sync site

on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:

permissions:
contents: write

jobs:
build:
name: Sync
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v3
- name: Install dependencies
run: pip install --user -r requirements.txt
- name: Update metadata
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./sync.py
- name: Commit and push
# Do not enable branch protection for main; it'll break this.
git config user.name 'CoreOS Bot'
git config user.email [email protected]
git add docs/data/*
git commit -m "Update data 📦"
git push
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/docs/.jekyll-cache/
/docs/_site
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Latest releases

This is a [small dashboard](https://coreos.github.io/latest-releases/) that
tracks the freshness of the latest releases of various CoreOS upstream
projects. The site is hosted in GitHub Pages and updated daily by a GitHub
Actions job.
36 changes: 36 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
thresholds:
# days
green: 60
yellow: 180

groups:
- name: Distro components
repos:
- coreos/afterburn
- coreos/bootupd
- coreos/console-login-helper-messages
- coreos/coreos-installer
- coreos/ignition
- coreos/rpm-ostree
- coreos/ssh-key-dir
- coreos/toolbox
- coreos/zincati
- ostreedev/ostree

- name: Utilities
repos:
- coreos/butane

- name: Libraries
repos:
- coreos/cap-std-ext
- coreos/go-json
- coreos/go-semver
- coreos/go-systemd
- coreos/ign-converter
- coreos/ignition-config-rs
- coreos/openat-ext
- coreos/openssh-keys
- coreos/stream-metadata-go
- coreos/stream-metadata-rust
- ostreedev/ostree-rs-ext
28 changes: 28 additions & 0 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!doctype html>
<title>{{ page.title }}</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">

<style>
html {
margin: .6em;
}
table {
border-collapse: collapse;
}
td {
padding: .2em .5em;
}
tbody tr:nth-child(odd) {
background-color: #e8e8e8;
}
#source {
float: right;
margin: .6em;
}
</style>

<div id=source>
<a href="https://github.com/coreos/latest-releases/">source</a>
</div>

{{ content }}
Binary file added docs/favicon.ico
Binary file not shown.
17 changes: 17 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
layout: default
title: Latest CoreOS upstream releases
---

# Latest CoreOS upstream releases

{% for group in site.data.repos.groups %}
### {{ group.name }}

| Repository | Current release | Release date | Commits since release (non-trivial / all) |
| --- | --- | --- | --- |
{% for repo in group.repos %}| [{{ repo.repo }}]({{ repo.url }}) | [{{ repo.release }}]({{ repo.release_url }}) | {% if repo.release_days < site.data.repos.green_thresh %}🟢{% elsif repo.release_days < site.data.repos.yellow_thresh %}🟨{% else %}🛑{% endif %} {{ repo.release_date }} ({{ repo.release_days }} days ago) | {{ repo.compare_nontrivial }} / [{{ repo.compare_commits }}]({{ repo.compare_url }}) |
{% endfor %}
{% endfor %}

Last updated: {{ site.data.repos.updated }}
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github3.py
PyYAML
72 changes: 72 additions & 0 deletions sync.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/python3

from datetime import datetime, timezone
import github3
import os
import re
import sys
import yaml

def main():
with open('config.yml') as fh:
conf = yaml.safe_load(fh)

token = os.getenv('GITHUB_TOKEN')
assert token
g = github3.login(token=token)

groups = []
for group in conf['groups']:
repos = []
groups.append({
'name': group['name'],
'repos': repos,
})

for desc in group['repos']:
owner, name = desc.split('/')
repo = g.repository(owner=owner, repository=name)

try:
release = repo.latest_release()
except github3.exceptions.NotFoundError:
print(
f"No releases (tags don't count): {desc}",
file=sys.stderr
)
continue
delta = datetime.now(timezone.utc) - release.published_at

compare = repo.compare_commits(
release.tag_name, repo.default_branch
)
nontrivial_commits = len([
c for c in compare.commits
# not merge commit
if len(c.parents) == 1 and
# not by Dependabot
(c.author is None or c.author.login != 'dependabot[bot]')
])

repos.append({
'repo': desc,
'url': repo.html_url,
'release': re.sub('^[a-z-]+', '', release.tag_name),
'release_url': release.html_url,
'release_date': release.published_at.strftime("%Y-%m-%d"),
'release_days': int(delta.total_seconds() / 86400),
'compare_commits': compare.ahead_by,
'compare_nontrivial': nontrivial_commits,
'compare_url': compare.html_url,
})

with open('docs/_data/repos.yml', 'w') as fh:
yaml.dump({
'groups': groups,
'updated': datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S"),
'green_thresh': conf['thresholds']['green'],
'yellow_thresh': conf['thresholds']['yellow'],
}, fh)

if __name__ == '__main__':
main()

0 comments on commit 5052ed6

Please sign in to comment.