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

Add compatibility with new dglc component in cdeps #75

Closed
wants to merge 517 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
517 commits
Select commit Hold shift + click to select a range
ecab154
Fixes BASECMP_CASE name
jasonb5 Oct 11, 2023
a786b10
Cleans up baselines
jasonb5 Oct 12, 2023
9b29244
Merge pull request #4488 from jedwards4b/cprnc_readme_update
jedwards4b Oct 12, 2023
1c6d7a1
Fixes handling non performance metrics
jasonb5 Oct 12, 2023
3596b55
Updates _check_for_memleak to be customized by the coupler
jasonb5 Oct 12, 2023
7ca44b7
add a clarification to README
jedwards4b Oct 13, 2023
e5b7048
Fixes workflow permissions
jasonb5 Oct 13, 2023
4c58427
Adds dispatching to testing workflow
jasonb5 Oct 13, 2023
af9b27f
Remove always pull option from testing workflow
jasonb5 Oct 13, 2023
7890021
Renames methods
jasonb5 Oct 13, 2023
d76f407
Fixes more naming
jasonb5 Oct 13, 2023
13e0e8b
Fixes striping newlines when reading baseline files
jasonb5 Oct 13, 2023
7780b1f
Fixes passing correct paths to memory/throughput bless functions
jasonb5 Oct 13, 2023
52ca0a1
Renames memory leak functions
jasonb5 Oct 13, 2023
de497e2
Add call in case_setup to run cam python script
lizziel Oct 13, 2023
69f7e36
Fixes black formatting
jasonb5 Oct 13, 2023
c452e8a
Use named string arguments when calling cam case setup script
lizziel Oct 13, 2023
ccb3b4e
Fixes baseline module organization
jasonb5 Oct 13, 2023
b856aa1
Fixes returning raw string from baseline
jasonb5 Oct 14, 2023
192eb32
Updates baseline documentation
jasonb5 Oct 14, 2023
3071dc3
Adds missing logging
jasonb5 Oct 14, 2023
7e30703
Fixes commenting preview that was never pushed
jasonb5 Oct 14, 2023
88255d5
Merge pull request #4491 from jasonb5/performance-baselines
jgfouca Oct 16, 2023
b5ea392
Remove deprecated 'distutils' package from ParamGen.
nusbaume Oct 16, 2023
56ea782
Jenkins_generic_job: Add --save-timing
jgfouca Oct 17, 2023
00f957c
Add test
jgfouca Oct 17, 2023
0a9126e
Merge pull request #4500 from nusbaume/paramgen_py12
jedwards4b Oct 18, 2023
741b0e6
Merge pull request #4501 from ESMCI/jgfouca/jenkins_save_timing
jgfouca Oct 19, 2023
89c5b55
Removes requiring an *-only option
jasonb5 Oct 19, 2023
01b7547
Fixes default bless behavior
jasonb5 Oct 20, 2023
df9c720
Adds feature to exclude tests
jasonb5 Oct 20, 2023
5436995
reduce the number of times env_batch is rewriten
jedwards4b Oct 20, 2023
055f35e
Merge pull request #4504 from jedwards4b/reduce_env_batch_updates
jedwards4b Oct 20, 2023
78f15dd
Fixes none value for exclude regex
jasonb5 Oct 23, 2023
9ffded5
Fixes function name
jasonb5 Oct 23, 2023
7050f24
Updates cmake macros
jasonb5 Oct 23, 2023
742547b
Merge pull request #4505 from ESMCI/fix_docker
jasonb5 Oct 24, 2023
0a676db
Merge branch 'master' into fix_bless_test_results
jasonb5 Oct 24, 2023
e47e4c1
Merge pull request #4502 from ESMCI/fix_bless_test_results
jgfouca Oct 24, 2023
eadb638
Fixes pes_file argument
jasonb5 Oct 24, 2023
50f0ada
Fixes create_test pesfile arg
jasonb5 Oct 24, 2023
f50f5f1
Fixes duplicate -g args
jasonb5 Oct 24, 2023
3b878e5
Adds missing checks to THROUGHPUT and MEMCOMP phases
jasonb5 Oct 24, 2023
ae788e8
Fixes memory/throughput check
jasonb5 Oct 24, 2023
b1d3d88
Adds unittests to cover bless_test_results module
jasonb5 Oct 25, 2023
89fa052
Fixes failing test
jasonb5 Oct 25, 2023
7b57911
Merge pull request #4506 from ESMCI/another_bless_test_results_fix
jgfouca Oct 25, 2023
d05da07
Moves skipping message to debug
jasonb5 Oct 27, 2023
a66c75e
Revert "Updates MEMCOMP and TPUTCOMP to DIFF if they're checked and f…
jasonb5 Oct 27, 2023
c6e3442
Updates performance bless to be separate from hist/nml
jasonb5 Oct 27, 2023
2f6d7c1
Updates MEMCOMP and TPUTCOMP to DIFF if they're checked and fail
jasonb5 Sep 20, 2023
9227c53
Updates bless perf flags
jasonb5 Oct 30, 2023
f71bec9
Merge pull request #4507 from ESMCI/yet_another_btr_update
jgfouca Oct 30, 2023
f7868d3
Adds commit hash and date to baseline files
jasonb5 Oct 31, 2023
603b530
Change cam.case_setup.py arguments to accompany changes in script in CAM
lizziel Oct 31, 2023
60d9fdc
Make gpu flags and case env vars visible to MPAS dycore
sjsprecious Nov 2, 2023
a9e1dc2
Add some comments
sjsprecious Nov 2, 2023
8b2e1ae
Merge pull request #4509 from sjsprecious/add_gpu_mpas
jedwards4b Nov 2, 2023
d9e5d3a
Merge pull request #4508 from ESMCI/update_perf_baselines
jgfouca Nov 2, 2023
06fa46a
Add --ignore-namelists to Jenkins scripts
amametjanov Nov 2, 2023
627a3bc
Changes applied by linter (black)
lizziel Nov 3, 2023
403680a
Merge pull request #4510 from ESMCI/jenkins_add_ignore_namelists
jgfouca Nov 3, 2023
dab95c1
Merge pull request #4497 from lizziel/case_setup_commands_for_cam
jedwards4b Nov 6, 2023
ded4546
Update e3smv3 pgn and tsc tests with L80 ICs for atm and lnd
wlin7 Nov 10, 2023
500c0df
Fixes separating std and performance blessing
jasonb5 Nov 13, 2023
126b568
Fixes tests
jasonb5 Nov 13, 2023
f5fd575
Merge pull request #4514 from ESMCI/update-perf-btr
jgfouca Nov 14, 2023
bb7022e
Update performance baseline checks
amametjanov Nov 18, 2023
952b815
srt pass
jedwards4b Nov 23, 2023
44f038c
add cprnc checkout
jedwards4b Nov 28, 2023
b0121c6
add cprnc checkout
jedwards4b Nov 28, 2023
0572ee5
add cprnc checkout
jedwards4b Nov 28, 2023
e681c94
need to get cprnc in container
jedwards4b Nov 28, 2023
5639672
need to add CMAKE_Fortran_FLAGS to Makefile
jedwards4b Nov 28, 2023
58943e8
correct cprnc directory
jedwards4b Nov 28, 2023
82149a6
Updates cprnc buildlib to check /externals for source
jasonb5 Dec 1, 2023
2c54a32
Removes cprnc clone to ensure each module correctly uses their own me…
jasonb5 Dec 1, 2023
c73d5be
Adds cprnc as submodule
jasonb5 Dec 1, 2023
3654a9c
try this
jedwards4b Dec 1, 2023
2530fe4
need this in init_cime too
jedwards4b Dec 1, 2023
aa30ec6
Adds cprnc submodule
jasonb5 Dec 1, 2023
e367c84
Updates init_e3sm to recursively init submodules
jasonb5 Dec 1, 2023
4425304
Fixes running checkout_externals in init_cime
jasonb5 Dec 1, 2023
686acf2
Updates container entrypoint.sh
jasonb5 Dec 2, 2023
1c9bfb5
Merge branch 'remove_cprnc' of https://github.com/jedwards4b/cime int…
jasonb5 Dec 2, 2023
cef9f89
Fixes black formatting
jasonb5 Dec 2, 2023
7c7b914
use cprnc as a submodule
jedwards4b Dec 2, 2023
1951091
Updates entrypoint.sh
jasonb5 Dec 2, 2023
4092e2f
Temporarily replace checkout_externals
jasonb5 Dec 2, 2023
35e15b0
Fixes clone cprnc after its been already present from submodule
jasonb5 Dec 2, 2023
d6a3da2
fix for test_gen_domain
jedwards4b Dec 4, 2023
1c7eda6
Merge pull request #4522 from jedwards4b/remove_cprnc
jedwards4b Dec 4, 2023
ef22a0c
Return latest value in read_baseline_file
amametjanov Dec 4, 2023
527012d
Merge branch 'master' into azamat/baselines/update-perf-info
jasonb5 Dec 5, 2023
ce0ae65
Fixes customizing baselines
jasonb5 Dec 5, 2023
4cd48d4
allow an external install of the mpi-serial library
jedwards4b Dec 6, 2023
5b8788b
currently only reads the first Macros file found, this fixes that so …
jedwards4b Dec 6, 2023
ea369e9
Merge pull request #4520 from ESMCI/azamat/baselines/update-perf-info
jgfouca Dec 6, 2023
4d70147
Fixes passing compiler/comp-interace to run_tests.py
jasonb5 Dec 6, 2023
68742fa
Fixes loading model customize earlier
jasonb5 Dec 6, 2023
de51de3
Stop running cpl7 unit tests
billsacks Dec 6, 2023
263a8ba
No longer build mct for unit tests
billsacks Dec 6, 2023
f10d656
Revert PR 4497
fischer-ncar Dec 7, 2023
da8b4d7
Merge pull request #4537 from ESMCI/fischer/revert_4497
fischer-ncar Dec 7, 2023
de9a478
more changes for mpi-serial
jedwards4b Dec 7, 2023
f7d44bb
Merge pull request #4536 from billsacks/remove_cpl7_unit_tests
billsacks Dec 7, 2023
b206acb
Add back changes from PR4497
fischer-ncar Dec 8, 2023
dee0cb9
fix submodule reference for cprnc
jedwards4b Dec 11, 2023
1a4f1e3
Merge pull request #4535 from jedwards4b/fix_test_sys_unittest.py
jedwards4b Dec 11, 2023
178b3a9
Merge pull request #4533 from jedwards4b/mpi_serial_bld_updates
jedwards4b Dec 11, 2023
cf6b3f0
Update to latest cprnc
jgfouca Dec 11, 2023
2ec465c
Merge pull request #4543 from ESMCI/jgfouca/update_cprnc
jedwards4b Dec 12, 2023
4ba6edd
Update cprnc submodule
jgfouca Dec 13, 2023
d68b8af
remove SMP_PRESENT and replace with BUILD_THREADED
jedwards4b Dec 14, 2023
1aea617
Merge pull request #4545 from ESMCI/jgfouca/update_cprnc_main
jgfouca Dec 15, 2023
a637ec7
v3 machines now working
jedwards4b Dec 11, 2023
ba073b7
v3 machines now working
jedwards4b Dec 11, 2023
7bd7522
remove cori from tests, fix unassigned var error
jedwards4b Dec 11, 2023
0865769
remove cori from tests, fix unassigned var error
jedwards4b Dec 11, 2023
059f36d
v3 list available
jedwards4b Dec 11, 2023
a58a5d6
add config_machines_version3 schema file
jedwards4b Dec 12, 2023
b88cdb1
remove bad debug print
jedwards4b Dec 12, 2023
320ff28
another debug print statement
jedwards4b Dec 12, 2023
561f19c
better error check
jedwards4b Dec 12, 2023
a449611
fix schema for v2
jedwards4b Dec 12, 2023
463b11e
fix schema for v2
jedwards4b Dec 12, 2023
d32b0d5
add documentation of schema variable
jedwards4b Dec 13, 2023
4e1bd76
cprnc subm
jgfouca Dec 15, 2023
102d408
Merge pull request #4542 from jedwards4b/reformat_config_machines
jedwards4b Dec 15, 2023
1c3b5c5
update externals for github testing
jedwards4b Dec 15, 2023
851fd12
Merge branch 'master' into replace_smp_present
jedwards4b Dec 15, 2023
cf3140d
need to merge to master
jedwards4b Dec 15, 2023
8b6381e
quit testing cesm with mct
jedwards4b Dec 15, 2023
826ef6f
try this
jedwards4b Dec 15, 2023
40d776e
userdefined_laptop_template is not a real machine
jedwards4b Dec 19, 2023
1621a03
remove NODENAME_REGEX from test
jedwards4b Dec 20, 2023
bcb77f9
fix some tests
jedwards4b Dec 20, 2023
1f38577
just update externals
jedwards4b Dec 20, 2023
93851a0
Merge pull request #4550 from jedwards4b/update_externals
jedwards4b Dec 20, 2023
d7ff4a4
need to update share tag
jedwards4b Dec 20, 2023
995b297
Merge branch 'update_externals' into replace_smp_present
jedwards4b Dec 20, 2023
ba27067
Fixes CIME Externals.cfg for all CESM testing
jasonb5 Dec 20, 2023
db2597c
Fixes cancelling system tests when a model/driver fails
jasonb5 Dec 20, 2023
7e9df5f
Merge pull request #4546 from jedwards4b/replace_smp_present
jedwards4b Dec 21, 2023
02fa602
Re-add newcase setup to create_clone
jgfouca Jan 3, 2024
58b7cab
Call case2 setup in system_tests_compare_two
jgfouca Jan 3, 2024
14fd58b
Merge pull request #4557 from ESMCI/jgfouca/fix_clone_test_cases
jgfouca Jan 3, 2024
3a4dcdc
Fix .env_mach_specific.sh when unsetting env
jgfouca Jan 4, 2024
9dd4fe5
Merge pull request #4558 from ESMCI/jgfouca/fix_env_mach_spec_del_env
jgfouca Jan 4, 2024
9b688a4
Update cprnc submodule
jgfouca Jan 10, 2024
e9c08a0
Merge pull request #4560 from ESMCI/jgfouca/update_cprnc_subm
jgfouca Jan 11, 2024
9456121
If chksum is off, don't try to download_checksum_file
jgfouca Jan 12, 2024
5abd938
Merge pull request #4561 from ESMCI/jgfouca/fix_chksum
jgfouca Jan 15, 2024
aedb8b9
Test using dynamic container
jasonb5 Jan 16, 2024
b09701e
Fixes workflow syntax
jasonb5 Jan 16, 2024
936cd18
Fixes workflow syntax
jasonb5 Jan 16, 2024
199602b
Fixes pushing container
jasonb5 Jan 16, 2024
4757ac7
Fixes container tag format
jasonb5 Jan 16, 2024
520d83b
Adds temp file to trigger build
jasonb5 Jan 17, 2024
8a31c9e
jenkins_generic_job: Should probe branch of main src repo, not cime repo
jgfouca Jan 17, 2024
f34b60e
Merge pull request #4566 from ESMCI/jgfouca/fix_jenkins_probe
jgfouca Jan 18, 2024
f0e6136
cprnc needs to have a tag for cesm
jedwards4b Jan 19, 2024
d2ec81a
Merge pull request #4567 from jedwards4b/update_cprnc_submodule
jedwards4b Jan 19, 2024
a127d2d
check .cime for a machine directory first
jedwards4b Jan 22, 2024
fbcfe8b
Switch from drv.log to med.log for nuopc COMP tests.
fischer-ncar Jan 22, 2024
4e0c713
Update Externals.cfg
fischer-ncar Jan 22, 2024
aadeaa2
Update to ccs_config_cesm0.0.91
fischer-ncar Jan 23, 2024
5f67534
Converts to pathlib
jasonb5 Jan 24, 2024
7b0bd56
Merge pull request #4569 from jedwards4b/machines_v3_fix
jasonb5 Jan 24, 2024
92f2964
Merge branch 'master' into update_workflow
jasonb5 Jan 24, 2024
9adf5e9
Merge pull request #4571 from ESMCI/fischer/test
fischer-ncar Jan 25, 2024
060b8e6
fix issue getting correct parameters for job subgroups
jedwards4b Jan 25, 2024
9480100
fix tests
jedwards4b Jan 25, 2024
6490e2e
Merge pull request #4570 from ESMCI/fischer/comp_fix
fischer-ncar Jan 29, 2024
da717c3
Fixes missing directory
jasonb5 Jan 30, 2024
3d961a9
Merge pull request #4572 from jedwards4b/jedwards/fix_dry_run_and_res…
jedwards4b Feb 1, 2024
425b145
Merge branch 'master' into update_workflow
jasonb5 Feb 1, 2024
b99db95
black reformat
jedwards4b Feb 2, 2024
4737a87
Merge branch 'master' into fischer/pr4497_redo
fischer-ncar Feb 2, 2024
475beb2
Merge pull request #4540 from ESMCI/fischer/pr4497_redo
jedwards4b Feb 2, 2024
7f529ea
case.submit: Fix no-batch mode
jgfouca Feb 2, 2024
635f786
Update cprnc to 1.05
jgfouca Feb 2, 2024
5810ea9
We never want file_util.copy_file to be verbose
jgfouca Feb 2, 2024
fabc297
black
jgfouca Feb 2, 2024
03dfa2c
Updates container to support v2/v3 config_machines
jasonb5 Feb 3, 2024
304af17
Fixes processing user v3 config_machines
jasonb5 Feb 3, 2024
da41ed2
Testing workflow
jasonb5 Feb 3, 2024
2b90917
Fixes job dependency
jasonb5 Feb 3, 2024
af3d330
Merge pull request #4575 from ESMCI/jgfouca/fix_no_batch
jgfouca Feb 5, 2024
8d8d718
Fixes pushing build
jasonb5 Feb 5, 2024
e281c43
Fixes unit testing step
jasonb5 Feb 5, 2024
c9eea88
Fixes testing working directory
jasonb5 Feb 5, 2024
9fee7bc
Adds debug statements
jasonb5 Feb 5, 2024
399c60d
Fixes checkout directory
jasonb5 Feb 5, 2024
9b49848
Fixes setting up working directory
jasonb5 Feb 5, 2024
89e012f
Debugging
jasonb5 Feb 5, 2024
1c6e138
Fixes setting working directory and configuring safe.directory
jasonb5 Feb 5, 2024
41a2c35
Enables running tests
jasonb5 Feb 5, 2024
019bb49
Debugs home directory
jasonb5 Feb 5, 2024
bcbae3d
Fixes copying .cime to /home/titters
jasonb5 Feb 5, 2024
55fa75d
Fixes setting up testing directory
jasonb5 Feb 5, 2024
203c357
Fixes safe.directory
jasonb5 Feb 5, 2024
fb5ab4e
Fixes broken test with shallow git clone
jasonb5 Feb 6, 2024
24ff828
Revert "Fixes broken test with shallow git clone"
jasonb5 Feb 6, 2024
fde2921
Fixes failing test due to shallow git clone
jasonb5 Feb 6, 2024
5a80a9b
Enable system testing
jasonb5 Feb 6, 2024
321d9dd
Fixes system testing image
jasonb5 Feb 6, 2024
f333f47
Fixes E3SM setup
jasonb5 Feb 6, 2024
a5c1e54
Removes old container workflow
jasonb5 Feb 6, 2024
4bf28be
Fix workflow
jasonb5 Feb 6, 2024
e146de6
Removes old cime dir
jasonb5 Feb 6, 2024
3fde6db
Fixes directory for E3SM system tests
jasonb5 Feb 6, 2024
32fc9eb
Fixes setting up E3SM testing
jasonb5 Feb 6, 2024
72b945a
Adds delay to prevent issues pulling image and fixes syncing cime sub…
jasonb5 Feb 6, 2024
a0a3fd3
Fixes creating artifacts for all system test runs
jasonb5 Feb 6, 2024
ad163a8
Fixes recursive submodule update for e3sm
jasonb5 Feb 6, 2024
01cc5f9
Upates workflow and inceases timeout
jasonb5 Feb 6, 2024
d40a5df
Fixes missing job dependency
jasonb5 Feb 6, 2024
8533ab5
Adds debug statement
jasonb5 Feb 7, 2024
523d611
Fixes hostname
jasonb5 Feb 7, 2024
206eece
Fix a string that should be raw
jgfouca Feb 6, 2024
bb3c9a6
Adds debug shell
jasonb5 Feb 7, 2024
a22dc16
Enable debug shell on failure
jasonb5 Feb 7, 2024
bc562d6
Merge pull request #4578 from ESMCI/jgfouca/raw_string_chars
jgfouca Feb 7, 2024
953f2a2
Just to trigger workflow
jasonb5 Feb 7, 2024
fcc113a
Fixes activating conda environemnt
jasonb5 Feb 7, 2024
391ec10
Trigger workflow
jasonb5 Feb 8, 2024
9a5f158
Disables testing for debugging
jasonb5 Feb 8, 2024
d90f5f2
Always enable shell
jasonb5 Feb 8, 2024
42e1d77
Fixes dry_run causing recursion
jasonb5 Feb 8, 2024
3f00354
Re-enables unit tests
jasonb5 Feb 8, 2024
d2104d7
Fixes pushing latest tag and limiting testing to pull requests
jasonb5 Feb 8, 2024
7fc53df
Fixes cloning e3sm if it exists, adds comments
jasonb5 Feb 14, 2024
0d50e27
Removes temporary trigger file
jasonb5 Feb 14, 2024
76d786b
Adds script and workflow to prune ghcr.io containers generated from t…
jasonb5 Feb 15, 2024
1b8213f
test if a component is running standalone
jedwards4b Feb 15, 2024
62a98d3
Update cprnc subm again
jgfouca Feb 15, 2024
662369b
Merge pull request #4579 from ESMCI/jgfouca/minor_cprnc_update
jgfouca Feb 15, 2024
fae887f
make that cam setup backward compatible
jedwards4b Feb 15, 2024
b0318c8
Fixes runs-on
jasonb5 Feb 16, 2024
8df8357
remove debug print statements
jedwards4b Feb 16, 2024
7a6069c
Fix spelling error in err message
jgfouca Feb 16, 2024
613db46
Adds description to ghcr-prune.py
jasonb5 Feb 16, 2024
0c18474
Adds class docstring for GitHubPaginate
jasonb5 Feb 16, 2024
1b208b8
Merge pull request #4563 from ESMCI/update_workflow
jgfouca Feb 16, 2024
2f38b10
Merge pull request #4580 from jedwards4b/standalone_component
jedwards4b Feb 16, 2024
34c2b12
black formatting for pgn.py tsc.py
rljacob Feb 16, 2024
12142ee
Merge pull request #4513 from ESMCI/wlin/reset_ics_e3smv3_pgn_tsc_tests
rljacob Feb 16, 2024
10753b8
Merge tag 'cime6.0.218' into HEAD
mvertens Feb 19, 2024
efee4eb
made the cime cprnc submodule use https rather than ssh
mvertens Apr 1, 2024
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
187 changes: 187 additions & 0 deletions .github/scripts/ghcr-prune.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
import argparse
import logging
import requests
import re
import json
from datetime import datetime
from datetime import timedelta

description = """
This script can be used to prune container images hosted on ghcr.io.\n

Our testing workflow will build and push container images to ghcr.io
that are only used for testing. This script is used to cleanup these
temporary images.

You can filter containers by any combination of name, age, and untagged.
"""

parser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawTextHelpFormatter)

parser.add_argument("--token", required=True, help='GitHub token with "repo" scope')
parser.add_argument("--org", required=True, help="Organization name")
parser.add_argument("--name", required=True, help="Package name")
parser.add_argument(
"--age", type=int, help="Filter versions by age, removing anything older than"
)
parser.add_argument(
"--filter", help="Filter which versions are consider for pruning", default=".*"
)
parser.add_argument("--untagged", action="store_true", help="Prune untagged versions")
parser.add_argument(
"--dry-run", action="store_true", help="Does not actually delete anything"
)

logging_group = parser.add_argument_group("logging")
logging_group.add_argument(
"--log-level", choices=("DEBUG", "INFO", "WARNING", "ERROR"), default="INFO"
)

kwargs = vars(parser.parse_args())

logging.basicConfig(level=kwargs["log_level"])

logger = logging.getLogger("ghcr-prune")


class GitHubPaginate:
"""Iterator for GitHub API.

Provides small wrapper for GitHub API to utilize paging in API calls.

https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api?apiVersion=2022-11-28
"""
def __init__(self, token, org, name, age, filter, untagged, **_):
self.token = token
self.session = None
self.url = (
f"https://api.github.com/orgs/{org}/packages/container/{name}/versions"
)
self.expired = datetime.now() - timedelta(days=age)
self.filter = re.compile(filter)
self.page = None
self.untagged = untagged

def create_session(self):
self.session = requests.Session()
self.session.headers.update(
{
"Accept": "application/vnd.github+json",
"Authorization": f"Bearer {self.token}",
"X-GitHub-Api-Version": "2022-11-28",
}
)

def grab_page(self):
if self.session is None:
raise Exception("Must create session first")

if self.url is None:
raise Exception("No more pages")

response = self.session.get(self.url)

response.raise_for_status()

remaining = int(response.headers["X-RateLimit-Remaining"])

logger.debug(f"Remaining api limit {remaining}")

if remaining <= 0:
reset = response.headers["X-RateLimit-Reset"]

raise Exception(f"Hit ratelimit will reset at {reset}")

try:
self.url = self.get_next_url(response.headers["Link"])
except Exception as e:
logger.debug(f"No Link header found {e}")

self.url = None

return self.filter_results(response.json())

def get_next_url(self, link):
match = re.match("<([^>]*)>.*", link)

if match is None:
raise Exception("Could not determine next link")

return match.group(1)

def filter_results(self, data):
results = []

logger.info(f"Processing {len(data)} containers")

for x in data:
url = x["url"]
updated_at = datetime.strptime(x["updated_at"], "%Y-%m-%dT%H:%M:%SZ")

logger.debug(f"Processing\n{json.dumps(x, indent=2)}")

try:
tag = x["metadata"]["container"]["tags"][0]
except IndexError:
logger.info(f'Found untagged version {x["id"]}')

if self.untagged:
results.append(url)

continue

if not self.filter.match(tag):
logger.info(f"Skipping {tag}, did not match filter")

continue

if updated_at < self.expired:
logger.info(
f"Pruning {tag}, updated at {updated_at}, expiration {self.expired}"
)

results.append(url)
else:
logger.info(f"Skipping {tag}, more recent than {self.expired}")

return results

def __iter__(self):
self.create_session()

return self

def __next__(self):
if self.page is None or len(self.page) == 0:
try:
self.page = self.grab_page()
except Exception as e:
logger.debug(f"StopIteration condition {e!r}")

raise StopIteration from None

try:
item = self.page.pop(0)
except IndexError:
raise StopIteration from None

return item

def remove_container(self, url):
if self.session is None:
raise Exception("Must create session first")

response = self.session.delete(url)

response.raise_for_status()

logger.debug(f"{response.headers}")


pager = GitHubPaginate(**kwargs)

for url in pager:
if kwargs["dry_run"]:
logger.info(f"Pruning {url}")
else:
pager.remove_container(url)
79 changes: 37 additions & 42 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,55 @@ on:
push:
branches:
- master
paths:
- 'doc/**'

pull_request:
branches:
- master
paths:
- 'doc/**'

workflow_dispatch:

permissions:
contents: read
jobs:
check-changes:
name: Check for changes to documentation
cleanup:
permissions:
contents: write # for git push
name: Cleanup branch previews
runs-on: ubuntu-latest
outputs:
any_changed: ${{ steps.changed-check.outputs.any_changed }}
if: ${{ github.event_name == 'push' }}
steps:
- uses: actions/checkout@v3
with:
ref: 'gh-pages'
fetch-depth: 0
lfs: true
- uses: tj-actions/changed-files@v32
id: changed-check
with:
files: doc
path: gh-pages
- name: Remove branch previews
run: |
pushd $GITHUB_WORKSPACE/gh-pages

for name in `ls branch/`
do
if [[ -z "$(git show-ref --quiet ${name})" ]]
then
git rm -rf branch/${name}
fi
done

git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git commit -m "Clean up branch previews"
git push
build-and-deploy:
permissions:
contents: write # for peaceiris/actions-gh-pages to push
pull-requests: write # to comment on pull requests
needs: check-changes
if: |
needs.check-changes.outputs.any_changed == 'true' &&
github.event.pull_request.head.repo.full_name == github.repository
needs: cleanup
if: ${{ always() }}
name: Build and deploy documentation
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -61,7 +80,9 @@ jobs:
run: |
make BUILDDIR=${PWD}/_build -C doc/ html
- name: Push PR preview
if: ${{ github.event_name == 'pull_request' }}
if: |
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{secrets.GITHUB_TOKEN}}
Expand All @@ -70,7 +91,9 @@ jobs:
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
- name: Comment about previewing documentation
if: ${{ github.event_name == 'pull_request' }}
if: |
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v6
with:
script: |
Expand Down Expand Up @@ -99,31 +122,3 @@ jobs:
destination_dir: './versions/master/html'
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
cleanup:
permissions:
contents: write # for git push
needs: build-and-deploy
name: Cleanup branch previews
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
steps:
- uses: actions/checkout@v3
with:
ref: 'gh-pages'
fetch-depth: 0
lfs: true
- name: Remove branch previews
run: |
for name in `ls branch/`
do
if [[ -z "$(git show-ref --quiet ${name})" ]]
then
git rm -rf branch/${name}
fi
done
- name: Commit and push local changes to gh-pages
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git commit -m "Clean up branch previews"
git push
24 changes: 24 additions & 0 deletions .github/workflows/ghcr-prune.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Prune ghcr.io container images
on:
schedule:
# run once a day
- cron: '0 2 * * *'

# Temporary to test
pull_request:

permissions: {}

jobs:
prune:
permissions:
packages: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- run: |
pip install requests

# remove containers older than 14 days and only generated by testing workflow
python .github/scripts/ghcr-prune.py --token ${{ secrets.GITHUB_TOKEN }} --org esmci --name cime --age 14 --filter sha- --untagged
24 changes: 24 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'Close stale issues and PRs'
on:
schedule:
# Run every day at 1:30AM
- cron: '30 1 * * *'
jobs:
stale:
permissions:
issues: write
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
with:
stale-issue-message: 'This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.'
days-before-stale: 90
days-before-close: 5
days-before-pr-close: -1
# Issues with this label are exempt from being checked if they are stale...
exempt-issue-labels: Low Priority
# Below are currently defaults, but given in case we decide to change
operations-per-run: 30
stale-issue-label: Stale
close-issue-reason: not_planned
Loading
Loading