Skip to content

Commit

Permalink
try running ci tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LaihoE committed Sep 21, 2023
1 parent 9779383 commit c62ec77
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 70 deletions.
62 changes: 8 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,12 @@ on:
permissions:
contents: read

jobs:
windows:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
target: [x86, x64]
defaults:
run:
working-directory: ./src/python

steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Build Wheels
uses: messense/maturin-action@v1
with:
command: publish
target: ${{ matrix.target }}
args: -i ${{ matrix.python-version }} --username ${{ secrets.PYPI_USERNAME }} --password ${{ secrets.PYPI_PASSWORD }} --no-sdist --skip-existing -m src/python/Cargo.toml

linux:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
target: [x86_64, aarch64]
defaults:
run:
working-directory: ./src/python
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Build Wheels
uses: messense/maturin-action@v1
with:
command: publish
target: ${{ matrix.target }}
args: -i ${{ matrix.python-version }} --username ${{ secrets.PYPI_USERNAME }} --password ${{ secrets.PYPI_PASSWORD }} --no-sdist --skip-existing -m src/python/Cargo.toml

macos:
runs-on: macos-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
target: [x86_64, aarch64]
python-version: ["3.10"]
target: [x86_64]
defaults:
run:
working-directory: ./src/python
Expand All @@ -77,6 +27,10 @@ jobs:
- name: Build Wheels
uses: messense/maturin-action@v1
with:
command: publish
command: build
target: ${{ matrix.target }}
args: -i ${{ matrix.python-version }} --username ${{ secrets.PYPI_USERNAME }} --password ${{ secrets.PYPI_PASSWORD }} --no-sdist --skip-existing -m src/python/Cargo.toml
args: -i --release
- name: Run tests
run: |
pip install pytest
pytest
2 changes: 1 addition & 1 deletion src/parser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl Parser {
self.tick = tick as i32;

if self.should_early_exit() {
break;
// break;
}

// Safety check
Expand Down
11 changes: 6 additions & 5 deletions src/python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,15 +971,16 @@ pub fn series_from_multiple_events(
.call_method1("insert", (0, col_name, pyobj))
.unwrap();
}
let pandas_df = pandas_df.call_method0("to_pandas").unwrap();

series_col_names.extend(py_col_names);
series_col_names.sort();

let kwargs = vec![("axis", 1)].into_py_dict(py);
let args = (series_col_names,);
pandas_df
let df = pandas_df
.call_method("reindex", args, Some(kwargs))
.unwrap();
pandas_df.to_object(py)
df.to_object(py)
});
vv.push((k, dfp));
}
Expand Down Expand Up @@ -1043,10 +1044,10 @@ pub fn series_from_event(
series_col_names.sort();
let kwargs = vec![("axis", 1)].into_py_dict(py);
let args = (series_col_names,);
pandas_df
let df = pandas_df
.call_method("reindex", args, Some(kwargs))
.unwrap();
pandas_df.to_object(py)
df.to_object(py)
});
Ok(dfp)
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions src/python/tests/data/python/game_time.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
time_last_injury,game_time,name,steamid,tick
1667.5469,1667.5625,tuhti sirpa,76561198055893769,98396
Binary file added src/python/tests/data/python/grenades.parquet
Binary file not shown.
1 change: 0 additions & 1 deletion src/python/tests/data/python/parse_grenades.json

This file was deleted.

11 changes: 11 additions & 0 deletions src/python/tests/data/python/rank_update.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
num_wins,rank_change,rank_new,rank_old,rank_type_id,user_name,user_steamid
12,-120.0,9879,9999,11,Cat,76561198194694750
6,0.0,0,0,11,Magnusti,76561198169206262
4,0.0,0,0,11,tuhti sirpa,76561198055893769
5,0.0,0,0,11,Axyod,76561198095275749
7,0.0,0,0,11,demondraq,76561198065528283
9,0.0,0,0,11,HanDBroms,76561198953819972
8,0.0,0,0,11,manzzer,76561198213975680
9,0.0,0,0,11,Steedy,76561198036306978
10,0.0,11711,0,11,oselbI4,76561198413993079
6,0.0,0,0,11,the dude airfrying his ballz,76561198241059228
75 changes: 66 additions & 9 deletions src/python/tests/e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,52 @@
from pandas.testing import assert_frame_equal
import json
import unittest
import pickle

ALL_PROPS = ['active_weapon_skin', 'FORWARD', 'LEFT', 'RIGHT', 'BACK', 'FIRE', 'RIGHTCLICK', 'RELOAD', 'INSPECT', 'USE', 'ZOOM',
'SCOREBOARD', 'WALK', 'pitch', 'yaw', 'game_time', 'rank', 'rank_if_win', 'rank_if_loss', 'rank_if_tie', 'mvps',
'active_weapon_original_owner', 'buttons', 'team_surrendered', 'team_rounds_total', 'team_name', 'team_score_overtime',
'team_match_stat', 'team_num_map_victories', 'team_score_first_half', 'team_score_second_half', 'team_clan_name',
'is_freeze_period', 'is_warmup_period', 'warmup_period_end', 'warmup_period_start', 'is_terrorist_timeout', 'is_ct_timeout',
'terrorist_timeout_remaining', 'ct_timeout_remaining', 'num_terrorist_timeouts', 'num_ct_timeouts', 'is_technical_timeout',
'is_waiting_for_resume', 'match_start_time', 'round_start_time', 'restart_round_time', 'is_game_restart?', 'game_start_time',
'time_until_next_phase_start', 'game_phase', 'total_rounds_played', 'rounds_played_this_phase', 'hostages_remaining',
'any_hostages_reached', 'has_bombites', 'has_rescue_zone', 'has_buy_zone', 'is_matchmaking', 'match_making_mode',
'is_valve_dedicated_server', 'gungame_prog_weap_ct', 'gungame_prog_weap_t', 'spectator_slot_count', 'is_match_started',
'n_best_of_maps', 'is_bomb_dropped', 'is_bomb_planed', 'round_win_status', 'round_win_reason', 'terrorist_cant_buy',
'ct_cant_buy', 'num_player_alive_ct', 'num_player_alive_t', 'ct_losing_streak', 't_losing_streak', 'survival_start_time',
'round_in_progress', 'i_bomb_site?', 'is_auto_muted', 'crosshair_code', 'pending_team_num', 'player_color', 'ever_played_on_team',
'clan_name', 'is_coach_team', 'comp_wins', 'comp_rank_type', 'is_controlling_bot', 'has_controlled_bot_this_round', 'can_control_bot',
'is_alive', 'armor', 'has_defuser', 'has_helmet', 'spawn_time', 'death_time', 'score', 'is_connected', 'player_name', 'player_steamid',
'fov', 'balance', 'start_balance', 'total_cash_spent', 'cash_spent_this_round', 'music_kit_id', 'leader_honors', 'teacher_honors',
'friendly_honors', 'kills_this_round', 'deaths_this_round', 'assists_this_round', 'alive_time_this_round', 'headshot_kills_this_round',
'damage_this_round', 'objective_this_round', 'utility_damage_this_round', 'enemies_flashed_this_round', 'equipment_value_this_round',
'money_saved_this_round', 'kill_reward_this_round', 'cash_earned_this_round', 'kills_total', 'deaths_total', 'assists_total',
'alive_time_total', 'headshot_kills_total', 'ace_rounds_total', '4k_rounds_total', '3k_rounds_total', 'damage_total',
'objective_total', 'utility_damage_total', 'enemies_flashed_total', 'equipment_value_total', 'money_saved_total',
'kill_reward_total', 'cash_earned_total', 'ping', 'move_collide', 'move_type', 'team_num', 'active_weapon',
'looking_at_weapon', 'holding_look_at_weapon', 'next_attack_time', 'duck_time_ms', 'max_speed', 'max_fall_velo',
'duck_amount', 'duck_speed', 'duck_overrdie', 'old_jump_pressed', 'jump_until', 'jump_velo', 'fall_velo', 'in_crouch',
'crouch_state', 'ducked', 'ducking', 'in_duck_jump', 'allow_auto_movement', 'jump_time_ms', 'last_duck_time', 'is_rescuing',
'weapon_purchases_this_match', 'weapon_purchases_this_round', 'spotted', 'spotted_mask', 'time_last_injury',
'direction_last_injury', 'player_state', 'passive_items', 'is_scoped', 'is_walking', 'resume_zoom', 'is_defusing',
'is_grabbing_hostage', 'blocking_use_in_progess', 'molotov_damage_time', 'moved_since_spawn', 'in_bomb_zone',
'in_buy_zone', 'in_no_defuse_area', 'killed_by_taser', 'move_state', 'which_bomb_zone', 'in_hostage_rescue_zone',
'stamina', 'direction', 'shots_fired', 'armor_value', 'velo_modifier', 'ground_accel_linear_frac_last_time',
'flash_duration', 'flash_max_alpha', 'wait_for_no_attack', 'last_place_name', 'is_strafing', 'round_start_equip_value',
'current_equip_value', 'time', 'health', 'life_state', 'X', 'Y', 'Z', 'active_weapon_name', 'active_weapon_ammo',
'total_ammo_left', 'item_def_idx', 'weapon_quality', 'entity_lvl', 'item_id_high', 'item_id_low', 'item_account_id',
'inventory_position', 'is_initialized', 'econ_item_attribute_def_idx', 'econ_raw_val_32', 'initial_value',
'refundable_currency', 'set_bonus', 'custom_name', 'orig_owner_xuid_low', 'orig_owner_xuid_high', 'fall_back_paint_kit',
'fall_back_seed', 'fall_back_wear', 'fall_back_stat_track', 'm_iState', 'fire_seq_start_time',
'fire_seq_start_time_change', 'is_player_fire_event_primary', 'weapon_mode', 'accuracy_penalty', 'i_recoil_idx',
'fl_recoil_idx', 'is_burst_mode', 'post_pone_fire_ready_time', 'is_in_reload', 'reload_visually_complete',
'dropped_at_time', 'is_hauled_back', 'is_silencer_on', 'time_silencer_switch_complete', 'orig_team_number',
'prev_owner', 'last_shot_time', 'iron_sight_mode', 'num_empty_attacks', 'zoom_lvl', 'burst_shots_remaining',
'needs_bolt_action', 'next_primary_attack_tick', 'next_primary_attack_tick_ratio', 'next_secondary_attack_tick',
'next_secondary_attack_tick_ratio', 'inventory']




def convert_same_dtypes(df, correct_df):
Expand All @@ -13,18 +59,28 @@ def convert_same_dtypes(df, correct_df):


class ParserTest(TestCase):
def test_parse_ticks(self):
def test_parse_event(self):
parser = DemoParser("tests/data/test.dem")
df = parser.parse_ticks(["X", "Y"], ticks=[79207])
df_correct = pd.read_json("tests/data/python/tick_test.json")
df = parser.parse_event("player_death", player=["X"], other=["total_rounds_played", "team_rounds_total"])
df_correct = pd.read_json("tests/data/python/parse_event.json")
df = convert_same_dtypes(df, df_correct)
assert_frame_equal(df, df_correct)

def test_parse_events(self):
def test_all_event_all_props(self):
parser = DemoParser("tests/data/test.dem")
df = parser.parse_event("player_death", player=["X"], other=["total_rounds_played", "team_rounds_total"])
df_correct = pd.read_json("tests/data/python/parse_events.json")
df = convert_same_dtypes(df, df_correct)
event_list = parser.parse_events(["all"], player=ALL_PROPS)
with open('tests/data/python/all_events_all_props.pkl', 'rb') as fp:
event_list_correct = pickle.load(fp)
event_list.sort(key = lambda x: x[0])
event_list_correct.sort(key = lambda x: x[0])
for (event, event_correct) in zip(event_list, event_list_correct):
assert_frame_equal(event[1], event_correct[1])
self.assertEqual(event[0], event_correct[0])

def test_all_ticks_props(self):
parser = DemoParser("tests/data/test.dem")
df = parser.parse_ticks(ALL_PROPS, ticks=[x for x in range(100000) if x % 100 == 0])
df_correct = pd.read_parquet("tests/data/python/all_tick_props.parquet")
assert_frame_equal(df, df_correct)

def test_header(self):
Expand All @@ -43,7 +99,7 @@ def test_list_game_events(self):

def test_parse_grenades(self):
parser = DemoParser("tests/data/test.dem")
df_correct = pd.read_json("tests/data/python/parse_grenades.json")
df_correct = pd.read_parquet("tests/data/python/grenades.parquet")
df = convert_same_dtypes(parser.parse_grenades(), df_correct)
assert_frame_equal(df, df_correct)

Expand All @@ -59,9 +115,10 @@ def test_game_time(self):
df = df[df["steamid"] == 76561198054530073]
time_last_injury = df.iloc[0]["time_last_injury"]
game_time = df.iloc[0]["time_last_injury"]
# This can also be slightly off is sub tick
# This can also be slightly off if is sub tick
self.assertEqual(time_last_injury, game_time)



if __name__ == '__main__':
unittest.main()

0 comments on commit c62ec77

Please sign in to comment.