21 Commits

Author SHA1 Message Date
Isaac
bbaf785ef8 Apply GoLand formatting (#7) 2025-03-25 04:52:59 +00:00
Isaac
6726754cfe Feat/static check (#5)
* ci: Add and update CI workflows; refine build and test steps

- Add new "Static" GitHub Actions workflow for running `staticcheck`
- Rename `go.yml` to `buildtest.yml` and update workflows
  - Add build and test jobs with caching, coverage, and result publishing
- Update `.gitignore` to exclude `.vscode` files

[.github/workflows/static.yml]
- Added a new GitHub Actions workflow named "Static".
- Configured the workflow to trigger on push and pull request events.
- Defined a CI job running on `ubuntu-latest`.
- Included steps for checking out the repository and running the `staticcheck` tool using a specific version (`2022.1.1`).
[.github/workflows/go.yml]
- Renamed the GitHub Actions workflow file from `go.yml` to `buildtest.yml`.
- Updated the file paths in the `push` trigger to reflect the new filename.
- Renamed the `unit_tests` job to `build` and added a "Build" step to run `go build -v ./...`.
- Introduced a cache setup step in the `build` job for Golang caches, improving build performance.
- Added a new `test` job that runs after the `build` job (with `needs: build` dependency).
   - `test` job includes permissions configuration for checks and pull requests.
   - Installs dependencies, runs tests with coverage, generates JUnit reports, and publishes test results.
- Removed unused permissions settings in the `build` job.
[.gitignore]
- Added `.vscode` to the ignored files in the `.gitignore` file.

* ci: Update checkout action to version 4 in workflow

* ci: Update staticcheck action to version 1.3.1

* ci: Update staticcheck action to use the latest version

* Fix/static errors (#4)

* refactor: Refactor piece enums to prioritize color over type

- Update piece composition order to prioritize color before piece type across relevant files (`Color | Piece` instead of `Piece | Color`)
- Remove `filterEnemies` method from `board/move.go`
- Update test cases and helper functions in `board/fen_test.go` to reflect the new composition order
- Adjust piece constant definitions in `board/pieces_test.go` for consistency with new composition order

[board/pieces_test.go]
- Updated the order of composition for piece constants to prioritize color before piece type (e.g., White | King instead of King | White).
[board/move.go]
- Removed the `filterEnemies` method, which filtered moves based on whether the captured piece was an enemy.
- No other changes to the file.
[board/fen_test.go]
- Reordered enum composition for clarity and consistency, changing the order from `Piece | Color` to `Color | Piece`.
- Updated test cases in `TestGenerateRow` to reflect the new order of enum composition.
  - Modified piece definitions in scenarios including "All Pawns", "Rooks Only", "Alternating Pawns", "Many Kings".
- Adjusted the helper function `getTestBoard` to match the new enum composition order in all board row definitions.

* ci: Refactor workflows by merging test into build job

- Update `.github/workflows/buildtest.yml` to merge "Test" job into "Build" job
- Add explicit permissions for checks and pull-requests in the "Build" job
- Integrate testing, coverage reporting, JUnit report generation, and result publishing into the "Build" job

[.github/workflows/buildtest.yml]
- Added explicit permissions for checks and pull-requests in the "Build" job.
- Removed the "Test" job and merged its steps into the "Build" job.
- Integrated testing, coverage reporting, JUnit report generation, and result publishing directly into the "Build" job.

* ci: Specify read permissions in CI job configuration
2025-03-24 19:51:38 +00:00
Isaac
612be866b2 Create dependabot.yml (#3)
* Create dependabot.yml

* Run CodeQL
2025-03-24 19:15:52 +00:00
MSWS
a7cb54819c test: Expand test coverage and refine CI workflow paths
- Update GitHub Actions workflow to allow broader branch triggers and include "testdata/*.json" in paths
- Expand test coverage and performance data validation in `board/move_test.go`

[.github/workflows/go.yml]
- Removed restriction on specific branches for push events.
- Added "testdata/*.json" to the paths triggering the workflow.
[board/move_test.go]
- Updated `knownPerfs` arrays for several test cases to include additional performance data across various depths.
- Expanded test coverage for positions like "Nf3 g5," "a4 a5," "Kiwipete," "Kiwipete - Passant," "Kiwipete - Checked," "Kiwipete - Minimized," "3 g3+," and "Gaviota."
- Improved the granularity of performance test data for better validation at deeper levels.
2025-03-23 17:04:07 -07:00
MSWS
0b518ed6f3 ci: Add always() condition to publish test results
- Add `if: always()` condition to "Publish Test Results" step in GitHub Actions workflow
- Apply minor formatting adjustments in `go.yml`

[.github/workflows/go.yml]
- Added a condition `if: always()` to the "Publish Test Results" step.
- No other notable changes except for formatting adjustments.
2025-03-23 13:10:52 -07:00
MSWS
df0a15242f ci: Refactor JUnit and Test Results step conditions
- Add `if: always()` condition to "Generate JUnit report" step in CI workflow
- Remove `if: always()` condition from "Publish Test Results" step in CI workflow

[.github/workflows/go.yml]
- Added an explicit condition `if: always()` to the "Generate JUnit report" step.
- Removed the `if: always()` condition from the "Publish Test Results" step.
2025-03-23 13:09:13 -07:00
MSWS
c25416305e ci: Refactor Go workflow to update test steps and formats
- Update `.github/workflows/go.yml` to improve test workflow by installing `go-junit-report`, splitting test steps, and switching test results to XML format

[.github/workflows/go.yml]
- Updated the workflow to install dependencies using `go-junit-report`.
- Replaced the "Run Tests with Coverage" step with separate steps for running tests, generating a JUnit report, and handling test results.
- Test result format changed from JSON to XML for publishing.
2025-03-23 13:07:03 -07:00
MSWS
31f49138f0 ci: Update Go version and test result handling in CI
Update Go workflow configuration

- Modify test command to store output in `test-results.json`
- Adjust publishing step to reference `test-results.json` directly
2025-03-23 13:00:12 -07:00
MSWS
e1c42edf96 ci: Update Go CI workflow with coverage and test publishing
- Add `permissions` section with write access for `checks` and `pull-requests` in GitHub Actions workflow
2025-03-23 12:56:11 -07:00
MSWS
b5bf1cb555 ci: Streamline CI workflow and update test data.
- Update test performance data in `board/move_test.go` with additional and higher depth analysis results for specific positions, ensuring no changes to test logic or structure.
- Simplify `.github/workflows/go.yml` by removing PR-specific actions, upgrading to Go 1.23, streamlining test result handling, and integrating `EnricoMi/publish-unit-test-result-action`.

[board/move_test.go]
- Added additional known performance data to specific test cases.
- Un-commented performance data values for select board positions.
- Adjusted data for positions like "Starting Position," "Kiwipete," and "6" by adding higher depth analysis results.
- No changes to test logic or structure, only updates to performance-related test data.
[.github/workflows/go.yml]
- Removed handling of pull requests and kept only push events triggering the workflow.
- Updated Go version from `^1.22` to `^1.23`.
- Consolidated steps for archiving and processing test results into a streamlined approach.
- Eliminated jobs for code coverage report and test summary.
- Integrated the `EnricoMi/publish-unit-test-result-action` for publishing test results.
- Reduced complexity by removing custom test summaries and PR comment posting logic.
- Simplified logic for handling test failures directly within the unit test step.
2025-03-23 12:54:08 -07:00
MSWS
48400eeac8 ci: Update Go workflow with refined test handling logic
- Refactor test processing by enhancing `jq` filters and splitting summary handling for `push` events
- Improve conditional logic for event-specific actions in workflow

[.github/workflows/go.yml]
- Updated Go version setup to use `^1.22`.
- Changed how test results are processed, modifying `jq` filters for counting passed and failed tests.
- Split test summary functionality:
  - Added a dedicated step to output test summaries specifically for `push` events in the GitHub Actions summary.
  - Refined pull request comment posting for test summaries.
- Improved conditional logic to differentiate actions based on the event type (`push` vs `pull_request`).
2025-03-23 12:27:17 -07:00
MSWS
9126c962bb ci: Update Go workflow to include testdata package
- Update test command in GitHub Actions workflow to include the `./testdata` package

[.github/workflows/go.yml]
- Updated the command for running tests to include the `./testdata` package.
2025-03-22 19:56:10 -07:00
MSWS
91b8eff72c ci: Make test workflows robust and handle test failures
- Update "Run Tests with Coverage" to allow failures and set an environment variable if tests fail
- Ensure code coverage and test summary jobs always run using `if: always()`
- Add step to explicitly fail workflow when tests fail
- Adjust permissions for `pull-requests` in workflows

[.github/workflows/go.yml]
- Updated the "Run Tests with Coverage" step to allow failures and set an environment variable if tests fail.
- Changed code coverage and test summary jobs to always run with the `if: always()` condition.
- Added a step to fail the workflow explicitly if tests failed.
- Adjusted permissions for `pull-requests` in certain workflows.
2025-03-22 19:53:43 -07:00
MSWS
8dd31f8a98 ci: Refactor Go workflow with test summary and improvements
- Simplify workflow trigger conditions and remove redundant event types in `.github/workflows/go.yml`
- Replace "Test" step with "Run Tests with Coverage" step, outputting results as JSON in `.github/workflows/go.yml`
- Introduce artifact archiving for test results (`test-results.json`) in `.github/workflows/go.yml`
- Refactor "Code Coverage Report" job for improved clarity and formatting in `.github/workflows/go.yml`
- Add a "Test Summary" job to parse test results and post PR comments in `.github/workflows/go.yml`

[.github/workflows/go.yml]
- Simplified workflow "trigger" conditions by removing extensive inline comments and unnecessary event types.
- Replaced the "Test" step with a new "Run Tests with Coverage" step that also outputs results as a JSON file.
- Introduced a new step to archive test results as a separate artifact ("test-results.json").
- Modified the "Code Coverage Report" job to adjust formatting and clarify steps without functional changes.
- Added a new "Test Summary" job:
  - Downloads and parses test results for passed/failed counts using `jq`.
  - Posts a test summary as a comment on pull requests using a sticky comment action.
2025-03-22 19:52:07 -07:00
MSWS
418e816e54 ci: Update Go CI workflow with triggers and code coverage jobs
```
Revamp CI workflow for improved clarity and functionality

- Rename the workflow from "Go Build and Test" to "CI" and update its trigger logic to better handle `push` and `pull_request` events.
- Refactor workflow jobs: rename `go-build-and-test` to `unit_tests` and introduce a new `code_coverage` job for pull request coverage reporting.
- Update dependencies to use the latest versions (`actions/checkout@v4`, `actions/setup-go@v4`, etc.) and simplify configuration (e.g., use `^1.22` for `go-version`).
- Add steps for generating and uploading code coverage details using `fgrosse/go-coverage-report@v1.1.1` and `actions/upload-artifact@v4`.
- Remove unused or redundant steps, such as searching for `go.mod` directories, and improve documentation with detailed comments about workflow purpose and trigger logic.
```

[.github/workflows/go.yml]
- Renamed the workflow from "Go Build and Test" to "CI".
- Updated the workflow triggers to include `pull_request` with events like `opened`, `reopened`, and `synchronize`, and restricted `push` events to the `main` branch.
- Added detailed explanation comments about the trigger logic and workflow purpose.
- Updated the `concurrency` section by removing it.
- Renamed the primary job from `go-build-and-test` to `unit_tests`.
- Replaced "Checkout code" with "Checkout repository" and updated to use `actions/checkout@v4`.
- Updated Go setup to use `actions/setup-go@v4` and simplified the `go-version` field to use `^1.22`.
- Added a step to run tests with code coverage output and specified a coverage profile file ("coverage.txt").
- Included a step to archive code coverage results using `actions/upload-artifact@v4`.
- Removed the step that searched for and processed directories with `go.mod`.
- Introduced a new `code_coverage` job to handle code coverage reporting specifically for pull requests, dependent on the `unit_tests` job.
- Configured permissions for `code_coverage` to allow commenting on pull requests.
- Added a step to generate a code coverage report using the `fgrosse/go-coverage-report@v1.1.1` action.
2025-03-22 19:51:55 -07:00
MSWS
8890fbbfe6 ci: Update Go version and improve test coverage setup
- Combine test commands in `go test` with coverage for `./...` and `./testdata/`
2025-03-22 17:58:01 -07:00
MSWS
54d81edb33 test: Refactor tests and workflows; comment out main function
- Comment out the main function implementation in `main.go` to disable functionality for now.
- Remove the "indirect" comment from the dependency declaration in `go.mod`.
- Add tests for the `testdata` directory.

[main.go]
- Commented out the entire main function implementation, including code for initializing the board, retrieving moves, iterating over moves, and printing outputs.
- No functional code remains active in the main function.
[go.mod]
- Removed the "indirect" comment from the dependency declaration.
[.github/workflows/go.yml]
- Updated the "Set up Go environment" step to specify Go version 1.22.8.
- Added an additional command to run tests specifically on the `testdata` directory.
- Ensured consistency and expanded test coverage in the workflow.
[board/board_test.go]
- Removed an unnecessary log statement from an En Passant test case.
- Tests verify UndoMove behavior:
  - Active player correctly switches between turns.
  - Original board position is restored after undoing moves.
  - Castling rights are properly updated upon undoing moves.
- Improved En Passant test cases:
  - Validation that pawn restoration works after an undo.
  - Correctly marks and restores En Passant availability from moves and FEN configurations.
  - Verifies board state integrity after multiple moves and undos involving En Passant captures.
2025-03-22 17:55:32 -07:00
MSWS
9bb1cadac7 refactor: Rename Board struct to Game and update references.
- Rename `Board` struct to `Game` across the codebase for better clarity and alignment with functionality.
- Update `board/move.go`: Adjust method receivers and references to use `Game` instead of `Board`, ensuring consistency.
- Update `board/board.go`: Refactor struct fields, method implementations, and FEN-related logic to accommodate the `Game` struct. Remove unused `Bitboard` type and clarify metadata fields (`HalfMoves`, `FullMoves`).
- Update `.github/workflows/go.yml`: Simplify the test command.
- Refactor tests (`board/move_test.go`, `board/board_test.go`) to align with the renamed `Game` struct and associated changes.
2025-03-22 16:48:51 -07:00
MSWS
c45525bf38 Fix CI path 2024-12-12 11:55:19 -08:00
MSWS
b89c74c4da Fix CI recursion logic 2024-12-12 11:54:53 -08:00
MSWS
066ba52fa9 More implementation of FEN + Unit Tests, add CI 2024-12-12 11:50:20 -08:00