diff --git a/.github/actions/changed-benchmark/action.yml b/.github/actions/changed-benchmark/action.yml new file mode 100644 index 00000000..bd448077 --- /dev/null +++ b/.github/actions/changed-benchmark/action.yml @@ -0,0 +1,33 @@ +name: 'Run Changed Benchmarks' +description: 'Run Changed Benchmarks' +inputs: + path: + description: 'Benchmark paths' + required: true + default_bench: + description: 'Default benchmark' + required: true +runs: + using: "composite" + steps: + - name: Get changes in applications + id: changed-benchmarks + uses: tj-actions/changed-files@v24.1 + with: + files: | + ${{ inputs.path }} + - name: Test applications + run: | + if [[ "${{steps.changed-benchmarks.outputs.all_changed_and_modified_files}}" != "" ]]; then + if [[ "${{steps.changed-benchmarks.outputs.all_changed_and_modified_files}}" == *"${{ inputs.path }}/__init__.py"* ]]; then + no_init=${${{steps.changed-benchmarks.outputs.all_changed_and_modified_files}}//"${{ inputs.path }}/__init__.py"/} + if [[ "$no_init" == "" ]]; then + pytest ${{ inputs.default_bench }} -n 2 -k "not backend0 and not backend1 and not backend2" --verbose --store + else + pytest "$no_init" -n 2 -k "not backend0 and not backend1 and not backend2" --verbose --store + fi + else + pytest ${{steps.changed-benchmarks.outputs.all_changed_and_modified_files}} -n 2 -k "not backend0 and not backend1 and not backend2" --verbose --store + fi + fi + shell: bash \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 024c0331..e87947bb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,3 +30,35 @@ jobs: run: python -m pip install -U tox - name: Run lint run: tox -elint + benchmark: + runs-on: ubuntu-latest + name: Run changed benchmarks + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 2 + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install Deps + run: | + python -m pip install --upgrade pip + pip install . + - name: Run changed application benchmarks + uses: ./.github/actions/changed-benchmark + with: + path: red_queen/games/applications + default_bench: red_queen/games/applications/run_bv.py + - name: Run changed mapping benchmarks + uses: ./.github/actions/changed-benchmark + with: + path: red_queen/games/mapping + default_bench: red_queen/games/mapping/map_misc.py + - name: Print results to log + run: python -m report.console_tables --storage results/ + - name: Upload original result file + uses: actions/upload-artifact@v3 + with: + name: results + path: results/ \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 03616958..b926c442 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,3 +25,26 @@ If black returns a code formatting error you can run `tox -eblack` to automatically update the code formatting to conform to the style. However, if `pylint` returns any error you will have to fix these issues by manually updating your code. + +## Continuous Integration + +The red-queen repo has a Continuous Integration (CI) action that test any new +or modified benchmarks being added in a pull request. This action was implemented +using [changed-files](https://github.com/tj-actions/changed-files). + +In the case that a new type of benchmark category is implemented, a new step +containing the directory of the python file that will be run with pytest should be +added to `.github/workflows/main.yml`. This step should call on our custom action +`changed-benchmark` which will detect any changed made to any benchmark of a specific +type. This action uses [changed-files](https://github.com/tj-actions/changed-files). You must also select +a default benchmark `` to run in case a change is made to an +`__init__.py` file without changing any benchmarks. +Your step should follow the format below: + +```yml + - name: Run changed benchmarks + uses: ./.github/actions/changed-benchmark + with: + path: red_queen/games/ + default_bench: red_queen/games// +``` \ No newline at end of file