Skip to content

Commit

Permalink
Merge pull request #1962 from AllenInstitute/feature/1962-compile-che…
Browse files Browse the repository at this point in the history
…ck-each-commit

Add CI compilation testing for each commit
  • Loading branch information
t-b authored Jan 4, 2024
2 parents 0496038 + c3e7dc3 commit 6c495f2
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 1 deletion.
15 changes: 15 additions & 0 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ jobs:
artifact_name: CompilationTest-${{ matrix.source }}-${{ fromJSON('["no-hardware","hardware"]')[matrix.hardware] }}-assets
timeout_minutes: 60

CompilationEachCommitTest:
name: |
👩🏾‍🔬 Compilation: Each commit
if: ${{ !inputs.is_called_workflow }}
uses: ./.github/workflows/test-igor-rebase-exec-workflow.yml
with:
job_name: |
👩🏾‍🔬 Compilation: Each commit
overwrite_job_name: ${{ inputs.is_called_workflow || false }}
experiment: Packages/tests/Compilation/CompilationTester.pxp
installer_flags: "-s git"
artifact_name: Compilation-Each-Commit-assets
timeout_minutes: 60

Documentation:
name: 👷 Documentation
runs-on: [ self-hosted, Linux, Docker ]
Expand Down Expand Up @@ -264,6 +278,7 @@ jobs:
needs:
# All jobs that create new artifacts
- BuildInstaller
- CompilationEachCommitTest
- CompilationTest
- Documentation
- TestWithoutHardware
Expand Down
107 changes: 107 additions & 0 deletions .github/workflows/test-igor-rebase-exec-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Test Rebase Exec Igor Workflow
run-name: Test Rebase Exec Igor Workflow
env:
# if this environment variable is set it will use the igor version from
# C:\Program Files\WaveMetrics\Igor Pro 9 Folder\IgorBinaries_x64_${CI_IGOR_REVISION}
CI_IGOR_REVISION: "r56565"
on:
workflow_call:
inputs:
job_name:
required: false
type: string
default: Run
description: The name of the main job
overwrite_job_name:
required: false
type: boolean
default: false
description: |
If set to true it will replace the name of the main job with the content of job_name
experiment:
required: true
type: string
description: The path to the Igor experiment file
target:
required: false
default: "['self-hosted', 'Windows', 'IgorPro']"
type: string
description: A JSON string with the tags for the target runner
installer_artifact_name:
required: false
default: BuildInstaller-dev-assets
type: string
description: The name of the artifact that holds the installer
installer_flags:
required: false
default: "-s installer"
type: string
description: The flags that should be used for the installer
artifact_name:
required: true
type: string
description: The name of the artifact that will be uploaded
expensive_checks:
required: false
default: "0"
type: string
description: Sets environment variable CI_EXPENSIVE_CHECKS
instrument_tests:
required: false
default: "0"
type: string
description: Sets environment variable CI_INSTRUMENT_TESTS
timeout_minutes:
required: false
default: 360
type: number
description: Defines the job timeout in minutes
defaults:
run:
shell: bash
jobs:

Test:
name: ${{ inputs.overwrite_job_name && inputs.job_name || 'Run' }}
runs-on: ${{ fromJson(inputs.target) }}
timeout-minutes: ${{ inputs.timeout_minutes }}
env:
CI_EXPENSIVE_CHECKS: ${{ inputs.expensive_checks }}
CI_INSTRUMENT_TESTS: ${{ inputs.instrument_tests }}
CI_SKIP_COMPILATION_TEST_DEFINES: "1"
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Initial repo config
run: tools/initial-repo-config.sh
- name: Fetch latest changes for main
run: git fetch origin main
- name: Fetch latest changes of branch
run: git fetch origin $GITHUB_HEAD_REF
- name: Checking out branch
run: git checkout -B $GITHUB_HEAD_REF origin/$GITHUB_HEAD_REF
- name: List of commits to operate on
run: git log --pretty=ref origin/main..
- name: Cleanup earlier rebase invocations
run: git rebase --abort 2>/dev/null || true
- name: Compile check each commit with ${{ inputs.experiment }}
run: |
git rebase --exec "git log --pretty=ref -n1" \
--exec "tools/clean_mies_installation.sh ${{ inputs.installer_flags }}" \
--exec "tools/autorun-test.sh -p ${{ inputs.experiment }} -v IP_9_64" origin/main
- name: Gather log files and crash dumps
if: always()
run: tools/gather-logfiles-and-crashdumps.sh
- name: upload artifacts
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: ${{ inputs.artifact_name }}
path: |
Packages/tests/**/JU_*.xml
Packages/tests/**/*.log
Diagnostics
**/*.jsonl
if-no-files-found: error
27 changes: 26 additions & 1 deletion Packages/tests/Compilation/CompilationTester.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ static Function SetDimensionLabelsFromWaveContents(WAVE/T wv)
endfor
End

// Read the environment variable `key` as number and if present, return 1 for
// all finite values not equal to 0 and 0 otherwise. Return `NaN` in all other
// cases.
static Function GetEnvironmentVariableAsBoolean(string key)
variable value, err

value = str2num(GetEnvironmentVariable(key)); err = GetRTError(-1)

if(numtype(value) == 0)
return !!value
endif

return NaN
End

Function/WAVE GetIncludes()
// keep sorted
Make/FREE/T includes = {"MIES_Include", \
Expand All @@ -34,6 +49,12 @@ Function/WAVE GetIncludes()
End

Function/WAVE GetDefines()

if(GetEnvironmentVariableAsBoolean("CI_SKIP_COMPILATION_TEST_DEFINES"))
Make/FREE/T/N=1 defines
return defines
endif

// keep sorted
Make/FREE/T defines = {"AUTOMATED_TESTING", \
"AUTOMATED_TESTING_DEBUGGING", \
Expand All @@ -56,5 +77,9 @@ End
/// UTF_TD_GENERATOR s1:GetDefines
Function TestCompilation([STRUCT IUTF_mData & md])

CHECK_COMPILATION(md.s0, defines = {md.s1})
if(strlen(md.s1) > 0)
CHECK_COMPILATION(md.s0, defines = {md.s1})
else
CHECK_COMPILATION(md.s0)
endif
End

0 comments on commit 6c495f2

Please sign in to comment.