From b03983913d4ea91fa89d0573e12e63d424372028 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 6 Dec 2020 11:45:04 +0000 Subject: [PATCH] Add tablegen workflow Fix workflow Fix workflow Fix workflow Update table --- .github/README.md | 48 ++++++++++++++++++++---------- .github/partial.jpg | Bin 0 -> 4832 bytes .github/tablegen.py | 41 +++++++++++++++++++++++++ .github/workflows/updatetable.yml | 32 ++++++++++++++++++++ 4 files changed, 105 insertions(+), 16 deletions(-) create mode 100644 .github/partial.jpg create mode 100644 .github/tablegen.py create mode 100644 .github/workflows/updatetable.yml diff --git a/.github/README.md b/.github/README.md index b6f2ee8..63d4873 100644 --- a/.github/README.md +++ b/.github/README.md @@ -4,23 +4,39 @@ Solutions to the [2020 Advent of Code](https://adventofcode.com/2020), in both P Go solutions are near direct copies of the Python solutions and may be added a few days afterwards. -**Key:** ![Completed][check] is completed, ![Incomplete][cross] is incomplete. +**Key:** ![Completed][check] is completed, ![Incomplete][cross] is incomplete, ![Partially complete][partial] is partially complete and ![Not yet attempted][pending] is released but not yet attempted. -| | Part 1 | Part 2 | | Part 1 | Part 2 | -|----|-------------------------|-------------------------|----|-------------------------|-------------------------| -| 1 | ![Completed][check] | ![Completed][check] | 2 | ![Completed][check] | ![Completed][check] | -| 3 | ![Completed][check] | ![Completed][check] | 4 | ![Completed][check] | ![Completed][check] | -| 5 | ![Completed][check] | ![Completed][check] | 6 | ![Completed][check] | ![Completed][check] | -| 7 | | | 8 | | | -| 9 | | | 10 | | | -| 11 | | | 12 | | | -| 13 | | | 14 | | | -| 15 | | | 16 | | | -| 17 | | | 18 | | | -| 19 | | | 20 | | | -| 21 | | | 22 | | | -| 23 | | | 24 | | | -| 25 | | | | | | + +| Day | | Python | Go | +|-----|---------------------|--------|----| +| 1 | ![Completed][check] | | | +| 2 | ![Completed][check] | | | +| 3 | ![Completed][check] | | | +| 4 | ![Completed][check] | | | +| 5 | ![Completed][check] | | | +| 6 | ![Not yet attempted][pending] | | | +| 7 | | | | +| 8 | | | | +| 9 | | | | +| 10 | | | | +| 11 | | | | +| 12 | | | | +| 13 | | | | +| 14 | | | | +| 15 | | | | +| 16 | | | | +| 17 | | | | +| 18 | | | | +| 19 | | | | +| 20 | | | | +| 21 | | | | +| 22 | | | | +| 23 | | | | +| 24 | | | | +| 25 | | | | + [check]: https://github.com/codemicro/adventOfCode/blob/master/.github/check.jpg?raw=true [cross]: https://github.com/codemicro/adventOfCode/blob/master/.github/cross.jpg?raw=true +[partial]: https://github.com/codemicro/adventOfCode/blob/master/.github/partial.jpg?raw=true +[pending]: https://github.com/codemicro/adventOfCode/blob/master/.github/asterisk.jpg?raw=true \ No newline at end of file diff --git a/.github/partial.jpg b/.github/partial.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d93de9c1fa5942394ffd007fea38bd36201777d2 GIT binary patch literal 4832 zcmeHKeN+=y7Qd4Kfr2X$u&AhGpgmT}CjvGXqIrb@kL; zU_}LLkCoOh{4AojdP*y{)^){&x`kSh3Mketf>u|HEq)@|HxY#0L;a_JE^p4f`OSUz z{@#7}zCZ4DTyp#X-U)HaIKVIr7NQ3n*I-wyO`i#%Qo$?$a0gdxGPojyp*I1W@*F2( zGlA`tv(Tah&xrn>9i>A$Tq0mGL)LJrw5NJrF(55yE#R8EKBIeo5YE2G7;~9ib zZ;IsIJ^2+6*J~qrsi7*7${a&v=@;f(h@|`_$(sBejZDj%7llXI6 zxh<0CB$p%1h=n}dsY2&O^3qgG@fgxV;Gu$0fry8!E!s?Zq9Sh47X3x?2A#B8tpaO^ zfVAj@Vwp@P6iI{<2_I?jDZ7bQ+xR9baEL)cP#TNgOzTM#&M>Mo$Xq&-hjwXK zlFA~@&&mHQ0?(J7aTqc}ry5;-C}1NLRjL=O8jVa8oW4+WY#ws$MVX+I?PfxlNKj<1 zMMK2q5hgm2hd=jH9zz;Pi;C0|k-U(Ra%D`+QVW@>H=qS7F+Lhs#>Rw+Wnp1_i9pQk zZkAmVL~;p6&1IRe?zdd9ARolJVYP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u{@@^;ExNgAoPKHdtbhJRvu!bzpc%+Z U@U-=Mau3Jl=T}u#-Ey@32SW5(V*mgE literal 0 HcmV?d00001 diff --git a/.github/tablegen.py b/.github/tablegen.py new file mode 100644 index 0000000..9f60531 --- /dev/null +++ b/.github/tablegen.py @@ -0,0 +1,41 @@ +from datetime import datetime +import re + +today_day = datetime.now().day + +readme_text = open(".github/README.md").read().strip().split("\n") + +start_flag = "" +end_flag = "" + +table_lines = [] +in_table = False +for line in readme_text: + line = line.strip() + + if line == end_flag: + in_table = False + if in_table: + table_lines.append(line) + elif line == start_flag: + in_table = True + +for i, l in enumerate(table_lines): + rs = re.match(r"\|\s*(\d{1,})\s*\|\s*\|.+\|.+\|", l) + if rs is not None and int(rs.group(1)) == today_day: + + table_lines[i] = f"| {today_day} | ![Not yet attempted][pending] | | |" + +counter = 0 +for i, line in enumerate(readme_text): + line = line.strip() + + if line == end_flag: + in_table = False + if in_table: + readme_text[i] = table_lines[counter] + counter += 1 + elif line == start_flag: + in_table = True + +open(".github/README.md", "w").write("\n".join(readme_text)) \ No newline at end of file diff --git a/.github/workflows/updatetable.yml b/.github/workflows/updatetable.yml new file mode 100644 index 0000000..78dd901 --- /dev/null +++ b/.github/workflows/updatetable.yml @@ -0,0 +1,32 @@ +name: Update table + +on: + workflow_dispatch: + schedule: + - cron: "1 5 * 12 *" + +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v2 + with: + ref: ${{ github.ref }} + fetch-depth: 0 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Run script + run: python .github/tablegen.py + + - name: Git commit and push + run: | + git config user.email 'actions@github.com' + git config user.name 'github-actions' + git add .github/README.md + git commit -m 'Update table' + git push origin HEAD:${{ github.ref }} \ No newline at end of file