From 3d0d39211dc384f4ce84e932145f3967e9f151bb Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sun, 17 Dec 2023 19:46:35 +0100 Subject: [PATCH] CI: Add GitHub Actions workflow --- .github/workflows/main.yml | 32 ++++++++++++++++++++++++++++++++ Makefile | 15 ++++++++++++--- rdmd_test.d | 6 +++--- 3 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000000..419e6f27a3 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,32 @@ +name: Main +on: + - pull_request # without merge conflicts + - push # branch or tag + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + main: + strategy: + fail-fast: false + matrix: + os: [ macos-latest, ubuntu-latest, windows-latest ] + dc: [ dmd-latest, ldc-latest ] + name: ${{ matrix.os }}, ${{ matrix.dc }} + runs-on: ${{ matrix.os }} + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - name: Install D compiler + uses: dlang-community/setup-dlang@v1.3.0 + with: + compiler: ${{ matrix.dc }} + - name: Build + shell: bash + run: make -j3 DMD=${{ startsWith(matrix.dc, 'ldc') && 'ldmd2' || 'dmd' }} + - name: Test + shell: bash + # /tmp is a symlink on Mac, and rdmd_test.d doesn't like it + run: ${{ startsWith(matrix.os, 'macos') && 'TMPDIR=$(cd /tmp && pwd -P)' || '' }} make -j3 DMD=${{ startsWith(matrix.dc, 'ldc') && 'ldmd2' || 'dmd' }} test diff --git a/Makefile b/Makefile index e13efd2654..a284388444 100644 --- a/Makefile +++ b/Makefile @@ -97,12 +97,21 @@ $(ROOT)/tests_extractor$(DOTEXE): tests_extractor.d # Build & run tests ################################################################################ +ifeq (windows,$(OS)) + # for some reason, --strip-trailing-cr isn't enough - need to dos2unix stdin + DIFF := dos2unix | diff --strip-trailing-cr +else + DIFF := diff +endif + +DOS2UNIX:=$(if $(findstring windows,$(OS)),| dos2unix,) + test_tests_extractor: $(ROOT)/tests_extractor$(DOTEXE) for file in ascii iteration ; do \ - $< -i "./test/tests_extractor/$${file}.d" | diff --strip-trailing-cr -p - "./test/tests_extractor/$${file}.d.ext"; \ + $< -i "./test/tests_extractor/$${file}.d" | $(DIFF) -u -p - "./test/tests_extractor/$${file}.d.ext"; \ done - $< -a betterc -i "./test/tests_extractor/attributes.d" | diff --strip-trailing-cr -p - "./test/tests_extractor/attributes.d.ext"; - $< --betterC -i "./test/tests_extractor/betterc.d" | diff --strip-trailing-cr -p - "./test/tests_extractor/betterc.d.ext"; + $< -a betterc -i "./test/tests_extractor/attributes.d" | $(DIFF) -u -p - "./test/tests_extractor/attributes.d.ext"; + $< --betterC -i "./test/tests_extractor/betterc.d" | $(DIFF) -u -p - "./test/tests_extractor/betterc.d.ext"; RDMD_TEST_COMPILERS = $(DMD) RDMD_TEST_EXECUTABLE = $(ROOT)/rdmd$(DOTEXE) diff --git a/rdmd_test.d b/rdmd_test.d index 706538bb3a..881569887f 100755 --- a/rdmd_test.d +++ b/rdmd_test.d @@ -431,7 +431,7 @@ void runTests(string rdmdApp, string compiler, string model) res = execute(rdmdArgs ~ [forceSrc.baseName()]); enforce(res.status == 0, res.output); - enforce(!res.output.canFind("compile_force_src")); + enforce(!res.output.canFind("compile_force_src"), res.output); } auto conflictDir = forceSrc.setExtension(".dir"); @@ -684,11 +684,11 @@ void runFallbackTest(string rdmdApp, string buildCompiler, string model) if an explicit --compiler flag is not provided, rdmd should search its own binary path first when looking for the default compiler (determined by the compiler used to build it) */ - string localDMD = buildPath(tempDir(), baseName(buildCompiler).setExtension(binExt)); + string localDMD = buildPath(dirName(rdmdApp), baseName(buildCompiler).setExtension(binExt)); std.file.write(localDMD, ""); // An empty file avoids the "Not a valid 16-bit application" pop-up on Windows scope(exit) std.file.remove(localDMD); auto res = execute(rdmdApp ~ [modelSwitch(model), "--force", "--chatty", "--eval=writeln(`Compiler found.`);"]); enforce(res.status == 1, res.output); - enforce(res.output.canFind(format(`spawn [%(%s%),`, localDMD.only)), localDMD ~ " would not have been executed"); + enforce(res.output.canFind(format(`spawn [%(%s%),`, localDMD.only)), localDMD ~ " would not have been executed. Output:\n" ~ res.output); }