Skip to content

Commit

Permalink
[CI] Add check:expired and fix:expired (open-telemetry#5808)
Browse files Browse the repository at this point in the history
  • Loading branch information
chalin authored Dec 17, 2024
1 parent d33b26e commit 256246e
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: |
PR_ACTION=$(echo $COMMENT | grep -oP '/fix:\K[-_0-9a-z]+')
echo "Action is $PR_ACTION"
ACTION_NAMES="all|dict|filenames|format|htmltest-config|i18n|markdown|refcache|submodules?|text"
ACTION_NAMES="all|dict|expired|filenames|format|htmltest-config|i18n|markdown|refcache|submodules?|text"
if [[ ! "$PR_ACTION" =~ ^($ACTION_NAMES)$ ]]; then
echo "Invalid action name: $PR_ACTION"
echo "Action name should be one of: $ACTION_NAMES"
Expand Down
9 changes: 0 additions & 9 deletions content/en/announcements/2024-community-awards.md

This file was deleted.

8 changes: 0 additions & 8 deletions content/en/announcements/eBPF.md

This file was deleted.

9 changes: 0 additions & 9 deletions content/en/announcements/kubecon-china.md

This file was deleted.

9 changes: 0 additions & 9 deletions content/en/announcements/kubecon-na-2024.md

This file was deleted.

10 changes: 0 additions & 10 deletions content/en/announcements/otel-community-day.md

This file was deleted.

9 changes: 0 additions & 9 deletions content/en/announcements/otel-localized.md

This file was deleted.

12 changes: 0 additions & 12 deletions content/ja/announcements/otel-community-day.md

This file was deleted.

10 changes: 0 additions & 10 deletions content/ja/announcements/otel-localized.md

This file was deleted.

10 changes: 0 additions & 10 deletions content/pt/announcements/otel-localized.md

This file was deleted.

12 changes: 0 additions & 12 deletions content/zh/announcements/otel-community-day.md

This file was deleted.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"build:production": "npm run _hugo -- --minify",
"build": "npm run _build",
"cd:public": "cd public &&",
"check:expired": "find content -name '*.md' | xargs ./scripts/list-expired.pl",
"check:filenames": "test -z \"$(npm run -s _ls-bad-filenames)\" || npm run -s _filename-error",
"check:format": "npm run _check:format && npm run _check:format:ja+zh || (echo '[help] Run: npm run fix:format'; exit 1)",
"check:i18n": "scripts/check-i18n.sh",
Expand All @@ -64,6 +65,7 @@
"diff:fail": "npm run _diff:check || (echo; echo 'ERROR: the files above have changed. Locally rerun `npm run test-and-fix` and commit changes'; echo; exit 1)",
"fix:all": "npm run all -- $(npm -s run _list:fix:*)",
"fix:dict": "find content/{en,es,fr,pt} layouts -name \"*.md\" -print0 | xargs -0 scripts/normalize-cspell-front-matter.pl",
"fix:expired": "npm run -s check:expired -- -q | xargs -r -I {} sh -c 'echo \"Deleting expired file: {}\" && rm {}'",
"fix:filenames": "npm run _rename-to-kebab-case",
"fix:format": "npm run format",
"fix:htmltest-config": "scripts/htmltest-config.sh",
Expand Down
24 changes: 24 additions & 0 deletions scripts/list-expired.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/perl -w

use Getopt::Long;

my $quiet = 0;
GetOptions('q' => \$quiet);

BEGIN {
my $num_days_in_past = 2;
my $seconds_in_a_day = 86400; # Number of seconds in a day
my $year_offset = 1900; # Offset for year in gmtime
my $month_offset = 1; # Offset for month in gmtime

my @gmtime = gmtime(time - $num_days_in_past * $seconds_in_a_day);
our $cut_off_date = sprintf "%04d-%02d-%02d", $gmtime[5] + $year_offset, $gmtime[4] + $month_offset, $gmtime[3];
}

while (<>) {
if (/^expiryDate:\s*([^#\n]+)/ && $1 le $cut_off_date) {
print "$ARGV";
printf "\t expired on %s", $1 unless $quiet;
print "\n";
}
}

0 comments on commit 256246e

Please sign in to comment.