Skip to content

Commit

Permalink
[fix/ISSUE-47] Patch duktaped files to support building for MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
azihassan committed Jan 4, 2024
1 parent 4b1b1c3 commit a0b2445
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 8 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
upload_release_assets_job:
strategy:
matrix:
version: [ { os: ubuntu-20.04, suffix: x86_64, extension: '' }, { os: windows-latest, suffix: win64, extension: '.exe' }]
version: [ { os: ubuntu-20.04, suffix: x86_64, extension: '' }, { os: windows-latest, suffix: win64, extension: '.exe' }, { os: macos-latest, suffix: macos, extension: '' }]

runs-on: ${{ matrix.version.os }}
needs: create_release_job
Expand All @@ -39,6 +39,13 @@ jobs:
with:
compiler: ldc-latest

- name: Fix duktaped build on OSX
if: matrix.version.suffix == 'macos'
run: |
dub upgrade
sed -i -e 's/version(Posix)/version(linux)/g' ~/.dub/packages/duktape/0.4.0/duktape/source/duk_config.d
sed -i -e 's/-linux/-posix/g' ~/.dub/packages/duktape/0.4.0/duktape/dub.json
- name: Build release
run: dub build -b release --compiler=ldc2

Expand All @@ -53,7 +60,7 @@ jobs:
tar cavf youtube-d-${{ matrix.version.suffix }}.zip youtube-d${{ matrix.version.extension }} libcurl.dll
- name: Prepare assets (Linux)
if: matrix.version.suffix == 'x86_64'
if: matrix.version.suffix == 'x86_64' || matrix.version.suffix == 'macos'
run: |
zip youtube-d-${{ matrix.version.suffix }}.zip youtube-d${{ matrix.version.extension }}
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
unit_test:
strategy:
matrix:
os: [ { name: ubuntu-20.04, extension: '' } , { name: windows-2019, extension: '.exe' }, { name: macos-latest, extension: '']
os: [ { name: ubuntu-20.04, extension: '' } , { name: windows-2019, extension: '.exe' }, { name: macos-latest, extension: '' } ]

runs-on: ${{ matrix.os.name }}

Expand All @@ -16,6 +16,13 @@ jobs:
- uses: mihails-strasuns/setup-dlang@v1
name: Install DMD

- name: Fix duktaped build on OSX
if: matrix.os.name == 'macos-latest'
run: |
dub upgrade
sed -i -e 's/version(Posix)/version(linux)/g' ~/.dub/packages/duktape/0.4.0/duktape/source/duk_config.d
sed -i -e 's/-linux/-posix/g' ~/.dub/packages/duktape/0.4.0/duktape/dub.json
- name: Build
run: dub build

Expand All @@ -31,7 +38,7 @@ jobs:
console_test:
strategy:
matrix:
os: [ { name: ubuntu-20.04, command: sh tests.sh, extension: '' } , { name: windows-2019, command: powershell.exe -file tests.ps1, extension: '.exe' }, { name: macos-latest, command: sh tests.sh, extension: '' }]
os: [ { name: ubuntu-20.04, command: sh tests.sh, extension: '' } , { name: windows-2019, command: powershell.exe -file tests.ps1, extension: '.exe' }, { name: macos-latest, command: sh tests-macos.sh, extension: '' }]

runs-on: ${{ matrix.os.name }}
needs: unit_test
Expand Down
31 changes: 31 additions & 0 deletions tests-macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
set -e

chmod +x youtube-d

./youtube-d -p -d --no-progress https://www.youtube.com/watch?v=R85MK830mMo

filename="Debugging Github actions-R85MK830mMo-18.mp4"
if [ ! -e "$filename" ]; then
echo "$filename not found"
exit 1
else
echo "[1/3] OK, $filename exists"
fi

expected_size=7079820
actual_size=$(stat -f %z Debugging\ Github\ actions-R85MK830mMo-18.mp4)
if [ $expected_size -ne $actual_size ]; then
echo "Wrong size. Expected $expected_size, found $actual_size"
exit 1
else
echo "[2/3] OK, size is correct"
fi

expected_hash="e7160d310e79a5a65f382b8ca0b198dd"
actual_hash=$(md5 < "$filename")
if [ $expected_hash != $actual_hash ]; then
echo "Wrong hash. Expected $expected_hash, found $actual_hash"
exit 1
else
echo "[3/3] OK, md5sum is correct"
fi
11 changes: 7 additions & 4 deletions tests.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
set -e
chmod +x youtube-d

./youtube-d -p -d --no-progress https://www.youtube.com/watch?v=R85MK830mMo
Expand All @@ -6,22 +7,24 @@ filename="Debugging Github actions-R85MK830mMo-18.mp4"
if [ ! -e "$filename" ]; then
echo "$filename not found"
exit 1
else
echo "[1/3] OK, $filename exists"
fi
echo "[1/3] OK, $filename exists"

expected_size=7079820
actual_size=$(du -b "$filename" | cut -f 1)
if [ $expected_size -ne $actual_size ]; then
echo "Wrong size. Expected $expected_size, found $actual_size"
exit 1
else
echo "[2/3] OK, size is correct"
fi
echo "[2/3] OK, size is correct"

expected_hash="e7160d310e79a5a65f382b8ca0b198dd"
actual_hash=$(md5sum "$filename" | cut -d " " -f 1)
if [ $expected_hash != $actual_hash ]; then
echo "Wrong hash. Expected $expected_hash, found $actual_hash"
exit 1
else
echo "[3/3] OK, md5sum is correct"
fi

echo "[3/3] OK, md5sum is correct"

0 comments on commit a0b2445

Please sign in to comment.