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

v2 improvements and fixes #83

Merged
merged 18 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions .github/actions/verify-d-compiler/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ inputs:
description: "Token to use when doing Github API request (for ldc-master)"
default: ${{ github.token }}
required: false
gdmd_sha:
descript: "Commit in D-programming-gdc/gdmd"
default: 'latest'
runs:
using: "composite"
steps:
Expand All @@ -17,22 +20,53 @@ runs:
with:
compiler: ${{ inputs.dc }}
gh_token: ${{ inputs.gh_token }}
gdmd_sha: ${{ inputs.gdmd_sha }}

- name: Verify D compiler ($DC)
shell: bash
run: $DC .github/hello.d && ./hello
run: |
mkdir -p d-ver-simple
pushd d-ver-simple
$DC ../.github/hello.d
if [[ ${DC} == *gdc* ]]; then
./a.out
else
./hello
fi
popd

- name: Verify D Compiler dmd-wrapper ($DMD)
shell: bash
run: |
mkdir -p d-ver-run
pushd d-ver-run
$DMD -run ../.github/hello.d
popd

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

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


- 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
run: |
mkdir -p d-ver-dub
pushd d-ver-dub
dub run --single -q ../.github/hello.d
popd
28 changes: 15 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ jobs:
with:
node-version: 20
- name: diff-ing dist/index.js
env:
NODE_OPTIONS: "--openssl-legacy-provider"
run: |
set -euxo pipefail
npm ci
Expand All @@ -48,8 +46,11 @@ jobs:
dmd-master,
]
include:
# 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-latest, dc: dmd-2.108.1-rc.1 }
- { os: macOS-latest, dc: dmd-2.109 }
- { os: macOS-latest, dc: dmd-latest }
- { os: macOS-latest, dc: dmd-master }
- { os: macOS-13, dc: dmd-2.108.1-rc.1 }
- { os: macOS-13, dc: dmd-2.107 }
- { os: macOS-13, dc: dmd-latest }
Expand Down Expand Up @@ -89,21 +90,21 @@ jobs:
with:
dc: ${{ matrix.dc }}

verify-gdmd:
verify-gdc:
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 }}
dc: [ gdc, gdc-12 ]
gdmd_sha: [ latest, 27c4c660f30d03e6cf467781bbbd3bbcc3db5758 ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/verify-d-compiler
with:
dc: ${{ matrix.dc }}
gdmd_sha: ${{ matrix.gdmd_sha }}

verify-default:
needs: verify-index-js-up-to-date
Expand All @@ -124,17 +125,19 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macOS-13 ]
dc: [ ldc-latest, dmd-latest, gdc, gdmd-12 ]
os: [ ubuntu-latest, windows-latest, macos-latest, macOS-13 ]
dc: [ ldc-latest, dmd-latest, gdc, gdc-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: windows-latest, dc: gdc-12 }
- { os: macOS-13, dc: gdc }
- { os: macOS-13, dc: gdmd-12 }
- { os: macOS-13, dc: gdc-12 }
- { os: macOS-latest, dc: gdc }
- { os: macOS-latest, dc: gdc-12 }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -143,7 +146,6 @@ jobs:
with:
compiler: ${{ matrix.dc }}
dub: ${{ matrix.dub }}
gdmd_sha: 'dc0ad9f739795f3ce5c69825efcd5d1d586bb013'

- name: Verify DUB version
run: |
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Run the typescript unittests
on:
push:
branches:
- "v*"
pull_request:
branches:
- "*"
defaults:
run:
shell: bash

jobs:
run-typescript-unittests:
name: Run all the typescript unittests
strategy:
fail-fast: false
matrix:
# This could be run on only one machine but run on all of them
# to make sure that other developers can run the tests on
# their system.
os: [ macos-latest, ubuntu-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Run `npm test`
run: |
set -euxo pipefail
npm ci
GITHUB_ENV= GITHUB_PATH= npm test
50 changes: 35 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ jobs:
exclude:
- { os: windows-latest, dc: gdc-12 }
- { os: macOS-latest, dc: gdc-12 }
# Or include them manually, optionally using gdmd instead of gdc
# Or include them manually
include:
- { os: ubuntu-latest, dc: gdmd }
- { os: ubuntu-latest, dc: gdc }

runs-on: ${{ matrix.os }}
steps:
Expand All @@ -85,7 +85,7 @@ jobs:
```


Simply add the setup-dlang action to your GitHub Actions workflow to automatically download and install a D compiler and package manager bundled with the compiler or separately downloaded. The action will automatically add the D binaries to the `PATH` environment variable and set the `DC` environment variable to the selected compiler.
Simply add the setup-dlang action to your GitHub Actions workflow to automatically download and install a D compiler and package manager bundled with the compiler or separately downloaded. The action will automatically add the D binaries to the `PATH` environment variable and set the `DC` and `DMD` environment variables to point to the to the selected compiler and to the dmd wrapper (`gdmd`, `ldmd2`, or `dmd`) of the compiler respectively.
Note, this behavior has been slightly adjusted in v2.
For more details check the changes below.

Expand All @@ -102,10 +102,11 @@ Examples:
```yml
- uses: dlang-community/setup-dlang@v2
with:
compiler: gdmd-12
compiler: gdc-12
# dub doesn't come with gdc
dub: latest
# Install gdmd from https://github.com/D-Programming-GDC/gdmd/blob/0a64b92ec5ad1177988496df4f3ca47c47580501/dmd-script
# instead of the master branch
gdmd_sha: '0a64b92ec5ad1177988496df4f3ca47c47580501'
```

Expand Down Expand Up @@ -146,22 +147,17 @@ All the ways it can be specified are:
- `ldc-master` - install the latest CI artifacts from https://github.com/ldc-developers/ldc/releases/CI.
This may requires a github api token.

- `gdc` - install the apt package `gdc`
- `gdc-12` - install the apt package `gdc-12`
- `gdmd` - install the apt packages `gdc` and `gdmd`
- `gdmd-12` - install the apt packages `gdc-12` and `gdmd`.
- `gdc` - install the apt package `gdc` and the `gdmd` script
- `gdc-12` - install the apt package `gdc-12` and the `gdmd` script
The available versions of gdc you can install are the versions available in the ubuntu repositories. For `ubuntu-22.04` (`ubuntu-latest` currently) those are `gdc-12`, `gdc-11`, and, `gdc` which corresponds to `gdc-11`. If in doubt check https://packages.ubuntu.com

Whatever compiler you specify you can expect that the environment variable `$DC` will be set to point to that compiler binary.
Additionally `$DMD` will point to the dmd wrapper of the aforementioned compiler if you require a consistent command line interface.
Currently absolute paths are used but you shouldn't depend on it.
The compiler bin folder is also added to `$PATH` so you can run programs like `rdmd` or `dub` without specifying full paths.
Less useful but the library directory of the compiler is also added to `$PATH` on windows and `LD_LIBRARY_PATH` on linux and macos.
The compilers are already configured to embed this path themselves so you really shouldn't have to consider this but know that it is set.

The distinction between `gdc` and `gdmd` is mostly what the `$DC` variable gets set to.
The `gdc` program uses command line arguments that don't match the ones used by `dmd` or `ldc`.
If your project uses these you can specify `gdmd` instead of `gdc` to get a more portable command line interface.

### dub

If you need a specific version of dub or if the D compiler doesn't come with one (`gdc`) you can explicitly install one.
Expand All @@ -179,14 +175,20 @@ Github [generates](https://docs.github.com/en/actions/security-guides/automatic-

### gdmd_sha

In case the `gdmd` script in the ubuntu repositories is too old you can specify a commit sha in https://github.com/D-Programming-GDC/gdmd and this action will use that to download a git version of the script.
The gdmd script is downloaded straight from the [upstream](https://github.com/D-Programming-GDC/gdmd) repository.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have latest as a symbolic value, otherwise updates to GDMD will requires updates here (and version bump).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to how to URL is calculated putting in master means that the script is downloaded from https://raw.githubusercontent.com/D-Programming-GDC/gdmd/master/dmd-script which is the latest version. No need to add any code.

Is it fine if it's left as master or do we make it latest for consistency. I'm fine we both but the former doesn't require changing any code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having latest for consistency and displaying this in example is better. This way if upstream decide to change their branch naming convention we can adapt our code without penalizing the user.

You can specify a custom commit sha or a branch name in case the default one is not appropriate for your use case.
Examples include `dc0ad9f739795f3ce5c69825efcd5d1d586bb013`, `master`, or the special value `latest`, which acts similarly to `master`.

Usage of `latest` instead of `master` is preferred for portability reasons.
Take as an example that upstream may rename the development branch to `main` or `trunk` in which case the old name `master` will not work anymore.

The default value for this input is `latest` and it is required when using GDC.

## Compiler support

### DMD

All DMD versions of releases and pre-releases since 2.065.0 on https://downloads.dlang.org/releases/2.x/ and https://downloads.dlang.org/pre-releases/2.x/ are supported.
Be aware that with the `macos-latest` (that currently resolve to `macos-14`) runners, the cpu architecture is arm64 and because of this dmd doesn't work on them.

DMD releases come with some extra tools like `rdmd` and `dub`. You are free to use them at your leisure.

Expand Down Expand Up @@ -229,7 +231,13 @@ Additionally, some tags of dub (`v1.29.1` - `v1.36.0`) don't have releases so yo

## Changes from v1

The most important change is the `$DC` environment variable becoming an absolute path instead of only the filename.
You can now specify `gdc` or `gdc-<version>` as inputs to this action, with the caveat that they only work on Linux runners.

Introduces the `DMD` variable which will point to the dmd wrapper of the selected compiler.
For example if you install `ldc-1.37.0` then `DC` will point to `<extracted_path>/ldc2` and `DMD` will point to `<extracted_path>/ldmd2`
This variable is setup for all compilers, automatically.

The most breaking change is the `$DC` environment variable becoming an absolute path instead of only the filename.
Depending on how it is used in scripts care must be taken to properly quote it especially on windows to avoid the `\` character being lost.

DMD versions prior to `dmd-2.072` will no longer install dub automatically.
Expand All @@ -239,3 +247,15 @@ When specifying `dmd-beta` the action may install `dmd-latest` if it determines
Example, if the latest DMD beta is `2.098.1_rc1` and the latest DMD release is `2.099.0` then `dmd-beta` will now resolve to `2.099.0` instead of `2.098.1_rc1`.

The minimum available version of dmd has been raised to `2.065.0`.

`dmd` is now allowed on `macos-latest` (arm64).
It should work even if it's a x86_64 binary thanks to the Rosetta compatibility layer.

Use arm64 binaries for dub on macos, when applicable.
Dub started publishing macos binaries since version [1.38.1](https://github.com/dlang/dub/releases/tag/v1.38.1)

Updated a lot of dependencies, changed the output target to es2022 from es2017.
This means that one no longer needs to set `NODE_OPTIONS=--openssl-legacy-provider` when building.

Added unittests.
To run them use `npm test`.
Loading