Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: enable tests CI #633

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflow-config/preflight-filters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dm:
- '**/*.dm'
- '**/*.dmm'
- '**/*.dmf'
- '**/*.dme'
114 changes: 50 additions & 64 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,96 +1,82 @@
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
- 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
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
6 changes: 3 additions & 3 deletions html/changelogs/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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."
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
14 changes: 9 additions & 5 deletions test/check-paths.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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" '(?<!<)<<(?!<)' -P
exactly 148 "<< uses" '(?<!<)<<(?!<)' -P
exactly 0 "incorrect indentations" '^( {4,})' -P
exactly 36 "text2path uses" 'text2path'
exactly 3 "update_icon() override" '/update_icon\((.*)\)' -P
Expand Down
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
8 changes: 3 additions & 5 deletions test/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -211,7 +211,7 @@ function run_code_tests {
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 "check icon state limit" "python3 test/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"
}

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
Loading