From 1d4e091fb6c777f73be44fd4045486f5b4d0ee04 Mon Sep 17 00:00:00 2001 From: G-J van Rooyen Date: Tue, 3 Sep 2024 17:32:00 +0200 Subject: [PATCH] Updated GHA for LLVM 18 (#31) * hello-word, leap, configuration updates Completed the hello-world and leap exercises. Updated configuration. * Add workflow in test.yml * Modified CI workflow to build Odin from source * Completed difference-of-squares, added format-all Completed the difference-of-squares practice exercise, and added the `bin/format-all.sh` script that recursively searches for .odin files and runs `odinfmt` on them. * Formatted source, added formatting to webhook All source files have been reformatted with the `odinfmt.json` spec. `bin/format-all.sh` is now run automatically on commit. * Added step to push autoformatting changes The `test.yml` GitHub workflow now pushes any changes that it makes, so that they persist in the repo. * Modified test.yml to not fail on no formatting `test.yml` now only attempts a commit and push if the automated formatting actually changed any files. * Added missing dashes in argument * Fixed bin/verify-exercises The verify-exercises script now runs the individual test for both concept and practice exercises, and is the default in the GitHub workflow. * Added the "grains" exercise Tests were lifted from the Gleam track. * Updated README; fixed test verification - The README now contains more thorough instructions on how to add a new exercise. - Fixed a variable name in the test runner that caused the "test all solutions" loop to run multiple times when verifying solutions. * Formatted config files with configlet * Fixed testing bug that clobbered stub solutions - Fixed bin/run-test.sh so that it doesn't delete the stub solution when a test fails. - Restored exercises, and added a NotImplemented error condition for the stubs. * Small code fixes. Updated README. - Ran the code formatter on source files. - Rehaul of the README to follow Python's example. * Added resistor-color exercise. Updated README. * Fixed and tested the test.yml action The workflow now uses a fixed commit hash to pull a specific release of Odin. We now use Ubuntu 22.04 which has the libffi8 dependency, and add clang as the only other dependency. * Implemented the resistor-color exercise * Removed configlet dependency in test.yml * Moved the exercise checklist to a linked GH issue * Test runner now checks that stub solution fails Added a check to bin/run-test.sh so that verifies that the stub solution does *not* pass any tests. Fixed hello-world.odin to actually be a stub. * Fixed incorrect stubs, added panics for stub procs - Improved bin/run-test.sh to add more visible color coding to the output. - Replaced NotImplemented error codes with a compile-time panic for procedures that have not yet been implemented. - Fixed stubs that were actually complete examples. * Removed fancy terminal color commands * Added support for skipping and unskipping tests - Exercises' unit tests were modified so that only a minimal subset of tests are initially enabled; the rest are skipped. - The test runner was modified to automatically unskip all test cases before running the tests. * Removed mention of NotImplemented in the README * Updated GHA to support the latest Odin version * Force replacement of old clang link * Added Odin release tag so that setup-odin doesn't build latest --- .github/workflows/test.yml | 19 +++++++++++++------ bin/run-test.sh | 2 +- exercises/practice/grains/grains.odin | 2 +- .../resistor-color/resistor_color.odin | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b90c5c5..38efb6d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,20 +13,27 @@ jobs: runs-on: ubuntu-22.04 steps: - - name: Update packages - run: sudo apt update + - name: Download Clang + run: wget https://apt.llvm.org/llvm.sh - - name: Install Clang - run: sudo apt -y install clang + - name: Set install script permissions + run: chmod u+x llvm.sh + + - name: Install Clang 18 + run: sudo ./llvm.sh 18 + + - name: Setup default version + run: sudo ln -f /usr/bin/clang-18 /usr/bin/clang - name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 - name: Setup Odin - uses: laytan/setup-odin@41f9612bfec760bbb68b05b5747f319afe7c48d8 + uses: laytan/setup-odin@3df60bd622575fda7efa4a3ec928f446bcae1a0a with: token: ${{ secrets.GITHUB_TOKEN }} - llvm-version: 14 + llvm-version: 18 + release: dev-2024-09 - name: Verify all exercises run: bin/verify-exercises diff --git a/bin/run-test.sh b/bin/run-test.sh index 53d94de..14a0d6c 100755 --- a/bin/run-test.sh +++ b/bin/run-test.sh @@ -63,7 +63,7 @@ function run_test() { # double-check that the example didn't accidentally get duplicated as the stub, this isn't # too critical for now. - if odin test ${tmp_path} ; then + if odin test ${tmp_path} 2> /dev/null ; then echo -e '\nERROR: The stub solution must not pass the tests!\n' exit 1 else diff --git a/exercises/practice/grains/grains.odin b/exercises/practice/grains/grains.odin index 9309232..aee82dc 100644 --- a/exercises/practice/grains/grains.odin +++ b/exercises/practice/grains/grains.odin @@ -1,6 +1,6 @@ package grains -Error :: enum {}// Please inspect the tests to see which error states to enumerate here. +Error :: enum {} // Please inspect the tests to see which error states to enumerate here. // Returns the number of grains on the specified square. diff --git a/exercises/practice/resistor-color/resistor_color.odin b/exercises/practice/resistor-color/resistor_color.odin index 70b2607..20a9853 100644 --- a/exercises/practice/resistor-color/resistor_color.odin +++ b/exercises/practice/resistor-color/resistor_color.odin @@ -1,6 +1,6 @@ package resistor_color -Color :: enum {}// Implement an enumeration of all the resistor colors. +Color :: enum {} // Implement an enumeration of all the resistor colors. code :: proc(color: Color) -> int {