From: classabbyamp <classabbyamp@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] .github/workflows/cycles.yaml: run on PRs, don't run on forks
Date: Wed, 06 Sep 2023 05:13:21 +0200 [thread overview]
Message-ID: <20230906031321.I5M5asQvnfZw7jRiCtaLOvI1tIiurxVp1IDkelow0g0@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-45933@inbox.vuxu.org>
[-- Attachment #1: Type: text/plain, Size: 826 bytes --]
There is an updated pull request by classabbyamp against master on the void-packages repository
https://github.com/classabbyamp/void-packages ci/cycle-lint
https://github.com/void-linux/void-packages/pull/45933
.github/workflows/cycles.yaml: run on PRs, don't run on forks
- running on forks is kinda useless and just gives people useless error messages if they sync their master branch at the wrong time
- run cycle check on PRs to catch cycles before they happen. this makes the cron cycle check more of a backup/just-in-case for things that slip past the CI
<!-- Uncomment relevant sections and delete options which are not applicable -->
#### Testing the changes
- I tested the changes in this PR: **YES**|**briefly**|**NO**
A patch file from https://github.com/void-linux/void-packages/pull/45933.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ci/cycle-lint-45933.patch --]
[-- Type: text/x-diff, Size: 6413 bytes --]
From 47b9d0735df69adc6422dfa07b30346386edd233 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Tue, 5 Sep 2023 22:48:55 -0400
Subject: [PATCH 1/3] common/scripts/xbps-cycles.py: improve caching
by storing the hash of the template in the cache, the cache can be invalidated
when the template is changed.
---
common/scripts/xbps-cycles.py | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/common/scripts/xbps-cycles.py b/common/scripts/xbps-cycles.py
index 7710381eb2925..1ae8f4199a133 100755
--- a/common/scripts/xbps-cycles.py
+++ b/common/scripts/xbps-cycles.py
@@ -1,8 +1,8 @@
#!/usr/bin/env python3
import os
-import sys
import glob
+import hashlib
import subprocess
import multiprocessing
@@ -11,6 +11,17 @@
import networkx as nx
+def hash_template(pkg, xbpsdir):
+ '''
+ Hashes a template with md5 for cache keying
+ '''
+ try:
+ with open(os.path.join(xbpsdir, 'srcpkgs', pkg, 'template'), "rb") as tmpl:
+ return hashlib.file_digest(tmpl, hashlib.md5).hexdigest()
+ except FileNotFoundError:
+ return '0'
+
+
def enum_depends(pkg, xbpsdir, cachedir):
'''
Return a pair (pkg, [dependencies]), where [dependencies] is the list
@@ -21,15 +32,21 @@ def enum_depends(pkg, xbpsdir, cachedir):
<xbpsdir>/xbps-src show-build-deps <pkg>
unless <cachedir>/deps-<pkg> file exist, in that case it is read.
+ To ensure the cache for a package is invalidated when its template changes,
+ the template is hashed and that hash is stored on the first line of the
+ package's cache file.
If the return code of this call nonzero, a message will be printed but
the package will treated as if it has no dependencies.
'''
if cachedir:
cachepath = os.path.join(cachedir, 'deps-' + pkg)
+ newhash = hash_template(pkg, xbpsdir)
try:
with open(cachepath) as f:
- return pkg, [l.strip() for l in f]
+ oldhash = f.readline().strip()
+ if oldhash == newhash:
+ return pkg, [l.strip() for l in f]
except FileNotFoundError:
pass
@@ -44,6 +61,7 @@ def enum_depends(pkg, xbpsdir, cachedir):
deps = [d for d in deps.decode('utf-8').split('\n') if d]
if cachedir:
with open(cachepath, 'w') as f:
+ print(newhash, file=f)
for d in deps:
print(d, file=f)
From 74b475df9bf348c29cc706ea0b50e1558b14608b Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Tue, 5 Sep 2023 20:10:58 -0400
Subject: [PATCH 2/3] .github/workflows/cycles.yaml: run on PRs, don't run on
forks
- running on forks is kinda useless and just gives people useless error
messages if they sync their master branch at the wrong time
- run cycle check on PRs to catch cycles before they happen. this makes
the cron cycle check more of a backup/just-in-case for things that
slip past the CI
- speed things up by caching dependencies in github's cache
functionality. this is only written by the scheduled job, not PRs.
---
.github/workflows/cycles.yml | 41 +++++++++++++++++++++++++++++++++---
1 file changed, 38 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/cycles.yml b/.github/workflows/cycles.yml
index 8eaecdc70287b..31075cccdf887 100644
--- a/.github/workflows/cycles.yml
+++ b/.github/workflows/cycles.yml
@@ -3,11 +3,18 @@ name: 'Cycle Check'
on:
schedule:
- cron: '0 18 * * *'
+ pull_request:
+ paths:
+ - 'srcpkgs/**'
jobs:
cycles:
runs-on: ubuntu-latest
+ # run only if on the main repo or on pull requests
+ if: ${{ github.event_name == 'pull_request' || github.repository_owner == 'void-linux' }}
permissions:
+ # this will only apply to scheduled runs
+ # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
issues: write
container:
image: 'ghcr.io/void-linux/void-buildroot-musl:20230904R2'
@@ -24,7 +31,7 @@ jobs:
# Upgrade again (in case there was a xbps update)
xbps-install -yu
# Install script dependencies
- xbps-install -y python3-networkx github-cli
+ xbps-install -y python3-networkx nodejs
- name: Clone and checkout
uses: classabbyamp/treeless-checkout-action@v1
@@ -34,9 +41,26 @@ jobs:
ln -s "$(pwd)" /hostrepo &&
common/travis/set_mirror.sh &&
common/travis/prepare.sh
- - name: Find cycles and open issues
+ - name: Load cached dependencies
+ id: cache-restore
+ uses: actions/cache/restore@v3
+ with:
+ key: xbps-cycles
+ path: /xbps-cycles
+ - name: Find cycles
run: |
- common/scripts/xbps-cycles.py | tee cycles
+ mkdir -p /xbps-cycles
+ common/scripts/xbps-cycles.py -c /xbps-cycles | tee cycles
+ - name: Save cached dependencies
+ if: ${{ github.event_name == 'schedule' }}
+ uses: actions/cache/save@v3
+ with:
+ key: ${{ steps.cache-restore.outputs.cache-primary-key }}
+ path: /xbps-cycles
+ - name: Open issues
+ if: ${{ github.event_name == 'schedule' }}
+ run: |
+ xbps-install -y github-cli
grep 'Cycle:' cycles | while read -r line; do
if gh issue list -R "$GITHUB_REPOSITORY" -S "$line" | grep .; then
printf "Issue on '%s' already exists.\n" "$line"
@@ -46,3 +70,14 @@ jobs:
done
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN }}
+ - name: Summary
+ run: |
+ if grep -q '^Cycle:' cycles; then
+ echo "Build cycles found:"
+ rv=1
+ else
+ echo "No cycles found:"
+ rv=0
+ fi
+ cat cycles
+ exit $rv
From 0f76076198a2f59a8ae5cd13a0fa86f33931c189 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Tue, 5 Sep 2023 21:04:08 -0400
Subject: [PATCH 3/3] chezmoi:
---
srcpkgs/chezmoi/template | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/srcpkgs/chezmoi/template b/srcpkgs/chezmoi/template
index f046f669df41c..7ecf6f84aef19 100644
--- a/srcpkgs/chezmoi/template
+++ b/srcpkgs/chezmoi/template
@@ -1,7 +1,7 @@
# Template file for 'chezmoi'
pkgname=chezmoi
version=2.38.0
-revision=1
+revision=2
build_style=go
go_import_path="github.com/twpayne/chezmoi/v2"
go_build_tags="noembeddocs noupgrade"
next prev parent reply other threads:[~2023-09-06 3:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-06 1:02 [PR PATCH] " classabbyamp
2023-09-06 1:04 ` [PR PATCH] [Updated] " classabbyamp
2023-09-06 1:16 ` classabbyamp
2023-09-06 3:02 ` classabbyamp
2023-09-06 3:03 ` classabbyamp
2023-09-06 3:13 ` classabbyamp [this message]
2023-09-06 3:14 ` classabbyamp
2023-09-07 16:08 ` [PR PATCH] [Updated] " classabbyamp
2023-09-07 16:09 ` classabbyamp
2023-09-07 16:12 ` classabbyamp
2023-09-07 16:27 ` classabbyamp
2023-09-07 16:29 ` classabbyamp
2023-09-07 16:31 ` classabbyamp
2023-09-07 16:44 ` classabbyamp
2023-09-07 16:53 ` Chocimier
2023-09-07 16:58 ` [PR PATCH] [Updated] " classabbyamp
2023-09-07 17:22 ` classabbyamp
2023-12-07 1:46 ` github-actions
2023-12-07 3:13 ` [PR PATCH] [Closed]: " classabbyamp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230906031321.I5M5asQvnfZw7jRiCtaLOvI1tIiurxVp1IDkelow0g0@z \
--to=classabbyamp@users.noreply.github.com \
--cc=ml@inbox.vuxu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).