From 985ab47e5ead8f5b7154fc1037a9cc43b980f7e3 Mon Sep 17 00:00:00 2001 From: Alexander-Block <47148212+Alexander-Block@users.noreply.github.com> Date: Sat, 23 Mar 2024 23:00:48 +0100 Subject: [PATCH 1/2] Add CI workflow for Linux --- .github/workflows/linuxCI.yml | 55 ++++++++++++++++++++++++++ APLSource/TestCases/Prepare.aplf | 6 +-- APLSource/TestCases/RunTestsForCI.aplf | 22 +++++++++++ 3 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/linuxCI.yml create mode 100644 APLSource/TestCases/RunTestsForCI.aplf diff --git a/.github/workflows/linuxCI.yml b/.github/workflows/linuxCI.yml new file mode 100644 index 0000000..c769af8 --- /dev/null +++ b/.github/workflows/linuxCI.yml @@ -0,0 +1,55 @@ +name: Linux CI + +on: + workflow_dispatch: + + push: + branches: + - main + + pull_request: + branches: + -main + +jobs: + linux: + name: "CI - Linux - Dyalog APL ${{ matrix.dyalogVersion }} with .NET ${{ matrix.dotnetVersion }}" + runs-on: ubuntu-latest + timeout-minutes: + 10 + strategy: + matrix: + include: + - dyalogVersion: "19.0" + dotnetVersion: "8.x" + fail-fast: false + steps: + - name: Install Dyalog APL + run: | + DEBFILE=`curl -o - -s https://www.dyalog.com/uploads/php/download.dyalog.com/download.php?file=docker.metafile | awk -v v="${{ matrix.dyalogVersion }}" '$0~v && /deb/ {print $3}'` + curl -o /tmp/dyalog.deb ${DEBFILE} + sudo dpkg -i /tmp/dyalog.deb + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ matrix.dotnetVersion }} + - name: Activate Tatin and Cider + run: LX="⎕SE.UCMD 'Tools.Activate all' ⋄ ⎕OFF" dyalog -b -s + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Tatin dependencies + run: LX="⎕SE.UCMD 'Tatin.Version' ⋄ ⎕SE.Tatin.(CreateReInstallParms ReInstallDependencies './tatin-dependencies_dev') ⋄ ⎕OFF" dyalog -b -s + - name: Run tests + run: | + runTest="⎕PW←500" + runTest="${runTest} ⋄ ⎕SE.UCMD 'Cider.Version'" + runTest="${runTest} ⋄ ⎕SE.Cider.DEVELOPMENT←1" + runTest="${runTest} ⋄ opts←⎕NS '' ⋄ opts.(batch checkPackageVersions folder)←1 0 '.'" + runTest="${runTest} ⋄ ⎕SE.Cider.OpenProject opts" + runTest="${runTest} ⋄ #.Cider.TestCases.RunTestsForCI ⋄ ⎕OFF 1" + LX="${runTest}" dyalog -b -s + - name: Upload code coverage report + uses: actions/upload-artifact@v4 + with: + name: code-coverage-report + path: ./TestResults/CodeCoverage.html \ No newline at end of file diff --git a/APLSource/TestCases/Prepare.aplf b/APLSource/TestCases/Prepare.aplf index 68b3bdf..4650678 100644 --- a/APLSource/TestCases/Prepare.aplf +++ b/APLSource/TestCases/Prepare.aplf @@ -11,17 +11,17 @@ flag←0 :If ⎕NEXISTS testPath :If ⎕NEXISTS testFilename,'.profile' - ind←('Code Coverage' 0 1)CommTools.Select'Append' 'Replace' 'Neither' + ind←('CodeCoverageExists@Code Coverage' 0 1)CommTools.Select'Append' 'Replace' 'Neither' →(3=ind)/0 flag←1 :If 2=ind 1 CodeCoverage.DeleteFiles testFilename :EndIf :Else - flag←0 CommTools.YesOrNo'Code coverage?' + flag←0 CommTools.YesOrNo'CodeCoverage@Code coverage?' :EndIf :Else - flag←0 CommTools.YesOrNo'Code coverage?' + flag←0 CommTools.YesOrNo'CodeCoverage@Code coverage?' :EndIf :If flag 3 ⎕MKDIR testPath ⍝ diff --git a/APLSource/TestCases/RunTestsForCI.aplf b/APLSource/TestCases/RunTestsForCI.aplf new file mode 100644 index 0000000..6c6684d --- /dev/null +++ b/APLSource/TestCases/RunTestsForCI.aplf @@ -0,0 +1,22 @@ + RunTestsForCI;rc;log + ⍝ Runs all test with the batch flag on and the debug flag off, + ⍝ prints the messages from the test run + ⍝ and closes the APL session with return code 0 if the test run + ⍝ was successful and return code 1 if not.\\ + ⍝ This test runner function is meant to be used for a CI + ⍝ pipeline. + + ⍝ Always produce code coverage report + CommTools.YesOrNo_Answers←1 2⍴'CodeCoverage@' 'y' + ⍝ Always replace a code coverage report if it is already present + CommTools.Select_Choices←1 2⍴'CodeCoverageExists@' 2 + Prepare + (rc log)←T.RunBatchTests 0 + ⎕←↑log + + :If 0<≢T.codeCoverage + {}CodeCoverage.ProcessData T.codeCoverage.filename + {}1 CodeCoverage.CreateReport T.codeCoverage.filename + :EndIf + + ⎕OFF rc From 44a3989a18cec06ed027e7aff24182d2fed7f776 Mon Sep 17 00:00:00 2001 From: Alexander-Block <47148212+Alexander-Block@users.noreply.github.com> Date: Sat, 23 Mar 2024 23:14:47 +0100 Subject: [PATCH 2/2] minor improvements - remove reinstallation of Tatin dependencies - always publish code coverage report --- .github/workflows/linuxCI.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/linuxCI.yml b/.github/workflows/linuxCI.yml index c769af8..6553ba5 100644 --- a/.github/workflows/linuxCI.yml +++ b/.github/workflows/linuxCI.yml @@ -37,8 +37,6 @@ jobs: run: LX="⎕SE.UCMD 'Tools.Activate all' ⋄ ⎕OFF" dyalog -b -s - name: Checkout repository uses: actions/checkout@v4 - - name: Install Tatin dependencies - run: LX="⎕SE.UCMD 'Tatin.Version' ⋄ ⎕SE.Tatin.(CreateReInstallParms ReInstallDependencies './tatin-dependencies_dev') ⋄ ⎕OFF" dyalog -b -s - name: Run tests run: | runTest="⎕PW←500" @@ -49,6 +47,7 @@ jobs: runTest="${runTest} ⋄ #.Cider.TestCases.RunTestsForCI ⋄ ⎕OFF 1" LX="${runTest}" dyalog -b -s - name: Upload code coverage report + if: always() uses: actions/upload-artifact@v4 with: name: code-coverage-report