From 443c1fa33df443fccc8c197420a84d6680ac7571 Mon Sep 17 00:00:00 2001 From: SuhEugene <32931701+SuhEugene@users.noreply.github.com> Date: Tue, 3 Oct 2023 20:39:57 +0300 Subject: [PATCH] Feat: enable tests CI --- .github/workflow-config/preflight-filters.yml | 5 + .github/workflows/test.yml | 114 ++++++++---------- html/changelogs/example.yml | 6 +- scripts/install-spaceman-dmm.sh | 10 +- test/check-paths.sh | 14 ++- .../check_icon_state_limit.py | 19 ++- test/run-test.sh | 12 +- 7 files changed, 91 insertions(+), 89 deletions(-) create mode 100644 .github/workflow-config/preflight-filters.yml mode change 100755 => 100644 test/check-paths.sh rename {tools/dmitool => test}/check_icon_state_limit.py (68%) diff --git a/.github/workflow-config/preflight-filters.yml b/.github/workflow-config/preflight-filters.yml new file mode 100644 index 0000000000..490cba3360 --- /dev/null +++ b/.github/workflow-config/preflight-filters.yml @@ -0,0 +1,5 @@ +dm: + - '**/*.dm' + - '**/*.dmm' + - '**/*.dmf' + - '**/*.dme' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 594b5f0b6f..4c9fd50901 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,53 +1,59 @@ name: Тестирование +permissions: + contents: read + on: workflow_dispatch: - push: - branches: - - master pull_request: branches: - - master - - merge-02-05-2021 - - testing + - master220 env: BYOND_MAJOR: "514" - BYOND_MINOR: "1557" - SPACEMAN_DMM_VERSION: suite-1.7 + BYOND_MINOR: "1588" + SPACEMAN_DMM_VERSION: suite-1.7.3 + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true jobs: + PreFlight: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - name: paths-filter + uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 + id: filter + with: + filters: .github/workflow-config/preflight-filters.yml + outputs: + dm: ${{ steps.filter.outputs.dm }} DreamChecker: runs-on: ubuntu-latest + needs: PreFlight + if: needs.PreFlight.outputs.dm == 'true' steps: - - uses: actions/checkout@v2.3.4 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - name: Setup Cache - uses: actions/cache@v2 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 with: - path: $HOME/spaceman_dmm/$SPACEMAN_DMM_VERSION + path: ~/spaceman_dmm/${{ env.SPACEMAN_DMM_VERSION }} key: ${{ runner.os }}-spacemandmm-${{ env.SPACEMAN_DMM_VERSION }} - name: Install Dreamchecker run: scripts/install-spaceman-dmm.sh dreamchecker - name: Run Dreamchecker run: ~/dreamchecker - - name: Run Failure Webhook - env: - JOB_STATUS: ${{ job.status }} - WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} - HOOK_OS_NAME: ${{ runner.os }} - WORKFLOW_NAME: ${{ github.workflow }} - if: ${{ failure() }} - run: | - wget https://raw.githubusercontent.com/DiscordHooks/github-actions-discord-webhook/master/send.sh - chmod +x send.sh - ./send.sh failure $WEBHOOK_URL Code: runs-on: ubuntu-latest + needs: DreamChecker steps: - - uses: actions/checkout@v2.3.4 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - name: Setup Cache - uses: actions/cache@v2 + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 with: - path: $HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR} + path: ~/BYOND-${{ env.BYOND_MAJOR }}.${{ env.BYOND_MINOR }} key: ${{ runner.os }}-byond-${{ env.BYOND_MAJOR }}-${{ env.BYOND_MINOR }} - name: Install Dependencies run: sudo apt-get install -y uchardet @@ -55,42 +61,22 @@ jobs: env: TEST: CODE run: test/run-test.sh - - name: Run Failure Webhook - env: - JOB_STATUS: ${{ job.status }} - WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} - HOOK_OS_NAME: ${{ runner.os }} - WORKFLOW_NAME: ${{ github.workflow }} - if: ${{ failure() }} - run: | - wget https://raw.githubusercontent.com/DiscordHooks/github-actions-discord-webhook/master/send.sh - chmod +x send.sh - ./send.sh failure $WEBHOOK_URL - Maps: - runs-on: ubuntu-latest - strategy: - matrix: - map_path: [example, sierra, torch, bearcat_inf, away_sites_testing] - steps: - - uses: actions/checkout@v2.3.4 - - name: Setup Cache - uses: actions/cache@v2 - with: - path: $HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR} - key: ${{ runner.os }}-byond-${{ env.BYOND_MAJOR }}-${{ env.BYOND_MINOR }} - - name: Run Tests - env: - TEST: MAP - MAP_PATH: ${{ matrix.map_path }} - run: test/run-test.sh - - name: Run Failure Webhook - env: - JOB_STATUS: ${{ job.status }} - WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} - HOOK_OS_NAME: ${{ runner.os }} - WORKFLOW_NAME: ${{ github.workflow }} - if: ${{ failure() }} - run: | - wget https://raw.githubusercontent.com/DiscordHooks/github-actions-discord-webhook/master/send.sh - chmod +x send.sh - ./send.sh failure $WEBHOOK_URL + # Maps: + # runs-on: ubuntu-latest + # needs: DreamChecker + # strategy: + # fail-fast: false + # matrix: + # map_path: [example, sierra, away_sites_testing] + # steps: + # - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + # - name: Setup Cache + # uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + # with: + # path: $HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR} + # key: ${{ runner.os }}-byond-${{ env.BYOND_MAJOR }}-${{ env.BYOND_MINOR }} + # - name: Run Tests + # env: + # TEST: MAP + # MAP_PATH: ${{ matrix.map_path }} + # run: test/run-test.sh diff --git a/html/changelogs/example.yml b/html/changelogs/example.yml index 65bd6b4483..06573a7a1f 100644 --- a/html/changelogs/example.yml +++ b/html/changelogs/example.yml @@ -6,7 +6,7 @@ # Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) # When it is, any changes listed below will disappear. # -# Valid Prefixes: +# Valid Prefixes: # bugfix # wip (For works in progress) # tweak @@ -22,7 +22,7 @@ # admin ################################# -# Your name. +# Your name. author: Unknown # Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. @@ -33,6 +33,6 @@ delete-after: True # SCREW THIS UP AND IT WON'T WORK. # Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. # Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. -changes: +changes: - rscadd: "Added a changelog editing system that should cause fewer conflicts and more accurate timestamps." - rscdel: "Killed innocent kittens." diff --git a/scripts/install-spaceman-dmm.sh b/scripts/install-spaceman-dmm.sh index ccb544bced..7321d48174 100755 --- a/scripts/install-spaceman-dmm.sh +++ b/scripts/install-spaceman-dmm.sh @@ -1,15 +1,15 @@ #!/bin/bash set -euo pipefail -if [ -f "$HOME/spaceman_dmm/$SPACEMAN_DMM_VERSION/$1" ]; +if [ -f ~/spaceman_dmm/$SPACEMAN_DMM_VERSION/$1 ]; then echo "Using cached $1." - cp "$HOME/spaceman_dmm/$SPACEMAN_DMM_VERSION/$1" ~/$1 + cp ~/spaceman_dmm/$SPACEMAN_DMM_VERSION/$1 ~/$1 else wget -O ~/$1 "https://github.com/SpaceManiac/SpacemanDMM/releases/download/$SPACEMAN_DMM_VERSION/$1" - mkdir -p $HOME/spaceman_dmm - cp ~/$1 $HOME/spaceman_dmm/$SPACEMAN_DMM_VERSION + mkdir -p ~/spaceman_dmm + cp ~/$1 ~/spaceman_dmm/$SPACEMAN_DMM_VERSION fi chmod +x ~/$1 -~/$1 --version \ No newline at end of file +~/$1 --version diff --git a/test/check-paths.sh b/test/check-paths.sh old mode 100755 new mode 100644 index 38af8045d3..2c55f3da17 --- a/test/check-paths.sh +++ b/test/check-paths.sh @@ -14,9 +14,13 @@ exactly() { # exactly N name search [mode] [filter] num="$(grep "$mode" "$search" $filter | wc -l || true)" if [ $num -eq $count ]; then - echo "$num $name" + echo "OK $num $name" else - echo "$(tput setaf 9)$num $name (expecting exactly $count)$(tput sgr0)" + echo "FAIL $num $name (expecting exactly $count)" + if [ $1 -lt 30 ]; then + echo "entries:" + grep "$mode" "$search" $filter + fi FAILED=1 fi } @@ -30,11 +34,11 @@ exactly 2 "/datum text paths" '"/datum' exactly 2 "/mob text paths" '"/mob' exactly 10 "/obj text paths" '"/obj' exactly 8 "/turf text paths" '"/turf' -exactly 142 "to_world uses" '\sto_world\(' -exactly 69 "to_world_log uses" '\sto_world_log\(' +exactly 141 "to_world uses" '\sto_world\(' +exactly 66 "to_world_log uses" '\sto_world_log\(' exactly 0 "world<< uses" 'world<<|world[[:space:]]<<' exactly 0 "world.log<< uses" 'world.log<<|world.log[[:space:]]<<' -exactly 134 "<< uses" '(? 512: bad_dmi_files.append((file_path, number_of_icon_states)) diff --git a/test/run-test.sh b/test/run-test.sh index 2c2f7fa1d3..b5f271f760 100755 --- a/test/run-test.sh +++ b/test/run-test.sh @@ -198,8 +198,8 @@ function run_code_tests { find_code_deps pip install --user PyYaml -q pip install --user beautifulsoup4 -q + pip install --user Pillow -q shopt -s globstar - run_test "check unit tests contains all maps" "scripts/validateTestingContainsAllMaps.sh" run_test_fail "maps contain no step_[xy]" "grep 'step_[xy]' maps/**/*.dmm" run_test_fail "maps contain no layer adjustments" "grep 'layer = ' maps/**/*.dmm" run_test_fail "maps contain no plane adjustments" "grep 'plane = ' maps/**/*.dmm" @@ -207,12 +207,12 @@ function run_code_tests { run_test_fail "no invalid spans" "grep -En \"<\s*span\s+class\s*=\s*('[^'>]+|[^'>]+')\s*>\" **/*.dm" run_test "code quality checks" "test/check-paths.sh" run_test "indentation check" "awk -f tools/indentation.awk **/*.dm" - run_test "check changelog example unchanged" "md5sum -c - <<< 'a4d3afef6ced70921c88d229b2c21af5 *html/changelogs_infinity/example.yml'" + run_test "check changelog example unchanged" "md5sum -c - <<< 'd79544262e83bedabee58552d9816c23 *html/changelogs/example.yml'" run_test "check tags" "python3 tools/TagMatcher/tag-matcher.py ." run_test "check color hex" "python3 tools/ColorHexChecker/color-hex-checker.py ." run_test "check punctuation" "python3 tools/PunctuationChecker/punctuation-checker.py ." - run_test "check icon state limit" "python3 tools/dmitool/check_icon_state_limit.py ." - run_test_ci "check changelog builds" "python3 tools/changelog/ss13_ru_genchangelog.py html/changelog_infinity.html html/changelogs_infinity" + run_test "check icon state limit" "python3 test/check_icon_state_limit.py ." + run_test_ci "check changelog builds" "python3 tools/changelog/ss13_genchangelog.py html/changelog.html html/changelogs" } function run_byond_tests { @@ -226,10 +226,8 @@ function run_byond_tests { if [[ "$CI" == "true" ]]; then msg "installing BYOND" ./install-byond.sh || exit 1 - source $HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR}/byond/bin/byondsetup + source ~/BYOND-${BYOND_MAJOR}.${BYOND_MINOR}/byond/bin/byondsetup fi - run_test_ci "check globals build" "python3 tools/GenerateGlobalVarAccess/gen_globals.py baystation12.dme code/_helpers/global_access.dm" - run_test "check globals unchanged" "md5sum -c - <<< '7686dffa04ef8cd53faa2b967c12707a *code/_helpers/global_access.dm'" run_test "build map unit tests" "scripts/dm.sh -DUNIT_TEST -M$MAP_PATH baystation12.dme" run_test "check no warnings in build" "grep ', 0 warnings' build_log.txt" run_test "run unit tests" "DreamDaemon baystation12.dmb -invisible -trusted -core 2>&1 | tee log.txt"