Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor code and implement more version formats for dmd and ldc and support gdc #77

Merged
merged 8 commits into from
May 30, 2024
38 changes: 38 additions & 0 deletions .github/actions/verify-d-compiler/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: 'setup-dlang test action'
description: 'Verify a D compiler installation'
inputs:
dc:
description: 'D compiler passed to setup-dlang'
required: false
default: ''
gh_token:
description: "Token to use when doing Github API request (for ldc-master)"
default: ${{ github.token }}
required: false
runs:
using: "composite"
steps:
- name: Install D compiler
uses: ./
with:
compiler: ${{ inputs.dc }}
gh_token: ${{ inputs.gh_token }}

- name: Verify D compiler ($DC)
shell: bash
run: $DC .github/hello.d && ./hello

- name: Verify D compiler with explicit bitness ($DC)
if: ${{ startsWith(inputs.dc, 'dmd') }}
shell: bash
run: $DC -m64 .github/hello.d && ./hello

- name: Verify D compiler ($DC, shared)
if: ${{ !startsWith(inputs.dc, 'g') }} # fails with gdc
shell: bash
run: $DC -shared .github/hello.d && ./hello

- name: Verify D compiler (dub)
if: ${{ !startsWith(inputs.dc, 'g') }} # dub doesn't come with gdc by default
shell: bash
run: dub run --single -q .github/hello.d
178 changes: 112 additions & 66 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,98 +6,135 @@ on:
pull_request:
branches:
- "*"
defaults:
run:
shell: bash

jobs:
verify:
name: Verify install
verify-index-js-up-to-date:
name: Verify that `dist/index.js` is up to date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: diff-ing dist/index.js
env:
NODE_OPTIONS: "--openssl-legacy-provider"
run: |
set -euxo pipefail
npm ci
npm run build
# exclude dist/index.js.map (different on Windows)
git diff --stat --exit-code HEAD -- ':!dist/index.js.map'

verify-dmd:
needs: verify-index-js-up-to-date
strategy:
max-parallel: 5
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
dc:
[
ldc-1.19.0,
ldc-latest,
ldc-beta,
ldc-master,
# Need fix for https://issues.dlang.org/show_bug.cgi?id=22942 for macOS
os: [ ubuntu-latest, windows-latest ]
dc: [
dmd,
dmd-2.099.1,
dmd-2.108.1-rc.1,
dmd-2.106,
dmd-2.106b,
dmd-latest,
dmd-beta,
dmd^3,
dmd-master,
"",
]
]
include:
- os: macOS-latest
arch: arm64
dc: ""
- os: macos-latest
arch: arm64
dc: ldc-1.30.0
- os: macOS-latest
arch: arm64
dc: ldc-latest
- os: macOS-latest
arch: arm64
dc: ldc-beta
- os: macOS-latest
arch: arm64
dc: ldc-master

# macOS-latest is arm64, not supported by dmd
# Needs >=dmd-2.107.1 due to https://issues.dlang.org/show_bug.cgi?id=24137
- { os: macOS-13, dc: dmd-2.108.1-rc.1 }
- { os: macOS-13, dc: dmd-2.107 }
- { os: macOS-13, dc: dmd-latest }
- { os: macOS-13, dc: dmd-master }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Install D compiler
uses: ./
- uses: ./.github/actions/verify-d-compiler
with:
compiler: ${{ matrix.dc }}
gh_token: ${{ secrets.GITHUB_TOKEN }}

- name: Verify D compiler ($DC)
shell: bash
run: $DC .github/hello.d && ./hello

- name: Verify D compiler with explicit bitness ($DC)
if: ${{ env['DC'] == 'dmd' }}
shell: bash
run: $DC -m64 .github/hello.d && ./hello

- name: Verify D compiler ($DC, shared)
shell: bash
run: $DC -shared .github/hello.d && ./hello
dc: ${{ matrix.dc }}

- name: Verify D compiler (dub)
run: dub run --single -q .github/hello.d
verify-ldc:
needs: verify-index-js-up-to-date
strategy:
max-parallel: 5
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macOS-latest, macOS-13 ]
dc: [
ldc,
ldc-1.19.0,
ldc-1.37.0-beta1,
ldc-1.36,
ldc-1.38b,
ldc-latest,
ldc-beta,
ldc^3,
ldc-master,
]
exclude:
# arm64 binaries are available since ldc-1.25.0
- { os: macOS-latest, dc: ldc-1.19.0 }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/verify-d-compiler
with:
dc: ${{ matrix.dc }}

- name: Install Node.js 20.x
uses: actions/setup-node@v4
verify-gdmd:
needs: verify-index-js-up-to-date
strategy:
max-parallel: 5
fail-fast: false
matrix:
# gdc and gdmd are only supported on ubuntu
os: [ ubuntu-latest ]
dc: [ gdmd, gdmd-12 ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/verify-d-compiler
with:
node-version: 20
dc: ${{ matrix.dc }}

- name: Ensure `dist/index.js` is up to date
env:
NODE_OPTIONS: "--openssl-legacy-provider"
run: |
set -euxo pipefail
npm ci
npm run build
# exclude dist/index.js.map (different on Windows)
git diff --stat --exit-code HEAD -- ':!dist/index.js.map'
shell: bash
verify-default:
needs: verify-index-js-up-to-date
name: Verify default compiler
strategy:
max-parallel: 5
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macOS-latest, macOS-13 ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/verify-d-compiler

dub:
name: Verify standalone DUB install
needs: verify-index-js-up-to-date
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macOS-latest ]
dc: [ ldc-latest, dmd-latest ]
dub: [ 1.19.0, 1.23.0, 1.24.0 ]
os: [ ubuntu-latest, windows-latest, macOS-13 ]
dc: [ ldc-latest, dmd-latest, gdc, gdmd-12 ]
dub: [ 1.19.0, 1.23.0, latest ]
exclude:
# Excluded because those are actually Linux executables
- { os: windows-latest, dub: 1.19.0 }
# gdc only supports Linux
- { os: windows-latest, dc: gdc }
- { os: windows-latest, dc: gdmd-12 }
- { os: macOS-13, dc: gdc }
- { os: macOS-13, dc: gdmd-12 }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -106,13 +143,18 @@ jobs:
with:
compiler: ${{ matrix.dc }}
dub: ${{ matrix.dub }}
gdmd_sha: 'dc0ad9f739795f3ce5c69825efcd5d1d586bb013'

- name: Verify DUB version
shell: bash
run: |
if [[ ${{ matrix.dub }} == 'latest' ]]
then
DUB_VERSION_FOR_TEST=$(curl -s https://api.github.com/repos/dlang/dub/releases/latest | jq -r '.name | sub("v(?<v>.+)"; .v)')
curlCmd=(
curl -s
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"
https://api.github.com/repos/dlang/dub/releases/latest
)
DUB_VERSION_FOR_TEST=$("${curlCmd[@]}" | jq -r '.tag_name | sub("v(?<v>.+)"; .v)')
else
DUB_VERSION_FOR_TEST=${{ matrix.dub }}
fi
Expand All @@ -127,3 +169,7 @@ jobs:
else
exit 1
fi

- name : Compile with dub
run: |
cd .github && dub run --single hello.d --compiler=${DC}
Loading