community-content icon indicating copy to clipboard operation
community-content copied to clipboard

Improve outdated tutorials check

Open jooola opened this issue 1 year ago • 2 comments

  • Extract summary building in a script that can be run locally
  • Include the date of the tutorials in the summary table
  • Add the year to the created issue title
  • Test the workflow when files are changed in a pull_request

jooola avatar Dec 10 '24 16:12 jooola

If you run outdated-tutorials-summary.sh on the first day of the month using cron: https://github.com/hetzneronline/community-content/blob/37f2d5629243834648170589ffc920d6300dc20a/.github/workflows/outdated-tutorials.yml#L4-L5

then tutorials written in the previous year, but not on the first day of the month will not be present in the table. You will need to wait two years to review them.

This condition will be false, because their timestamps will be bigger: https://github.com/hetzneronline/community-content/blob/37f2d5629243834648170589ffc920d6300dc20a/hack/outdated-tutorials-summary.sh#L43

To reproduce, replace:

  • last_year_timestamp=$(date +'%s' -d '1 year ago') with last_year_timestamp=$(date +'%s' -d '2023-12-01 00:00:00')
  • last_year_month=$(date +'%m' -d '1 year ago') with last_year_month=12

This tutorial will not be present.

wpdevelopment11 avatar Dec 14 '24 18:12 wpdevelopment11

@jooola

I made small changes. See here: https://github.com/wpdevelopment11/community-content/blob/stale/hack/outdated-tutorials-summary.sh

I dropped timestamps, I think they are not needed here. Script should work correctly now.

Now yq commands are executed only when there're really needed. This reduces the execution time on my machine from 5,2s to 2s.

Why you placed a script to the hack directory?


While looking at your changes I found a bug in the old script 😀.

Try to execute the following command, it prints nothing:

head -n 20 tutorials/cloudflare-website-protect/01.en.md | awk '/^---$/{f=!f;next}f'

If you add \r to the awk command it prints the front matter:

head -n 20 tutorials/cloudflare-website-protect/01.en.md | awk '/^---\r$/{f=!f;next}f'

Basically the previous script was broken for tutorials that used Windows style line endings.

wpdevelopment11 avatar Apr 17 '25 10:04 wpdevelopment11

Superseded by #1235

jooola avatar Sep 03 '25 13:09 jooola