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 aff0b60 commit b3bf046
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 6 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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
env:
DMD: ${{ startsWith(matrix.dc, 'ldc') && 'ldmd2' || 'dmd' }}
N: ${{ startsWith(matrix.os, 'macos') && '3' || '2' }}
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 -j$N DMD=$DMD
- name: Test
shell: bash
run: make -j$N DMD=$DMD test
- name: 'Windows: Build and test with MODEL=32'
if: runner.os == 'Windows'
shell: bash
run: make -j$N DMD=$DMD MODEL=32 all test
17 changes: 14 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 All @@ -113,6 +120,10 @@ ifeq ($(VERBOSE_RDMD_TEST), 1)
override VERBOSE_RDMD_TEST_FLAGS:=-v
endif

ifeq (osx,$(OS))
# /tmp is a symlink on Mac, and rdmd_test.d doesn't like it
test_rdmd: export TMPDIR=$(shell cd /tmp && pwd -P)
endif
test_rdmd: $(ROOT)/rdmd_test$(DOTEXE) $(RDMD_TEST_EXECUTABLE)
$< $(RDMD_TEST_EXECUTABLE) $(MODEL_FLAG) \
--rdmd-default-compiler=$(RDMD_TEST_DEFAULT_COMPILER) \
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 b3bf046

Please sign in to comment.