Skip to content

Commit

Permalink
Feat: Enable tests CI
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhEugene committed Oct 3, 2023
1 parent 9acca07 commit 004a838
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 67 deletions.
81 changes: 31 additions & 50 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,72 @@
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: "1589"
SPACEMAN_DMM_VERSION: suite-1.7.3

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
- name: Run Tests
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
needs: DreamChecker
strategy:
matrix:
map_path: [example, sierra, torch, bearcat_inf, away_sites_testing]
map_path: [example, sierra, away_sites_testing]
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}
key: ${{ runner.os }}-byond-${{ env.BYOND_MAJOR }}-${{ env.BYOND_MINOR }}
Expand All @@ -83,14 +75,3 @@ jobs:
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
10 changes: 5 additions & 5 deletions scripts/install-spaceman-dmm.sh
Original file line number Diff line number Diff line change
@@ -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
~/$1 --version
12 changes: 5 additions & 7 deletions test/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,21 @@ 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"
run_test_fail "ensure nanoui templates unique" "find nano/templates/ -type f -exec md5sum {} + | sort | uniq -D -w 32 | grep nano"
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 - <<< '683a3e0d21b90581ae6e4c95052d461e *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 {
Expand All @@ -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"
Expand Down
19 changes: 14 additions & 5 deletions tools/dmitool/check_icon_state_limit.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
import argparse, re, sys
from os import path, walk
import dmitool # This import is why this script is here. If someone can import this file cleanly from [repo root]/test/ instead, feel free
from PIL import Image

opt = argparse.ArgumentParser()
opt.add_argument('dir', help='The directory to scan for *.dmi files with an excess number of icon states.')
args = opt.parse_args()

STATE_PATTERN = r'^state\s*='

def get_states_count(path):
try:
im = Image.open(path)
return len(re.findall(STATE_PATTERN, im.info["Description"], re.MULTILINE))
except (Image.UnidentifiedImageError):
print("{0} is not a valid image".format(path))
exit(1)

if(not path.isdir(args.dir)):
print('Not a directory')
sys.exit(1)

bad_dmi_files = []

# This section parses all *.dmi files in the given directory, recursively.
for root, subdirs, files in walk(args.dir):
for filename in files:
if filename.endswith('.dmi'):
file_path = path.join(root, filename)
dmi_info = dmitool.info(file_path)
number_of_icon_states = len(dmi_info["states"])
number_of_icon_states = get_states_count(file_path)
if number_of_icon_states > 512:
bad_dmi_files.append((file_path, number_of_icon_states))

Expand Down

0 comments on commit 004a838

Please sign in to comment.