Skip to content

Commit

Permalink
CI: Add GitHub Actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kinke committed Dec 17, 2023
1 parent 13f0430 commit 5cd476a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,19 @@ $(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

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)
Expand Down
6 changes: 3 additions & 3 deletions rdmd_test.d
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
}

0 comments on commit 5cd476a

Please sign in to comment.