Skip to content

Commit

Permalink
Github actions (#9259)
Browse files Browse the repository at this point in the history
* Github actions

* Clean up

* Split neko installation to platform files

* Fix hl

best test is disabled test

* Windows hl fix

* Disable lua for windows
  • Loading branch information
RblSb authored Jun 2, 2020
1 parent c3748c4 commit efbd40b
Show file tree
Hide file tree
Showing 20 changed files with 1,151 additions and 15 deletions.
617 changes: 617 additions & 0 deletions .github/workflows/main.yml

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions extra/github-actions/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package;

import sys.FileSystem;
import sys.io.File;
import haxe.io.Path;
using StringTools;

class Main {

static final matchImport = ~/^([ \t]*)@import (.+)$/gm;
static final matchRunnable = ~/^([ \t]*)jobs:/gm;

static function main():Void {
final folder = FileSystem.absolutePath(".");
final outFolder = "../../.github";

iterFolderItems(folder, (dir, name) -> {
final ext = Path.extension(name);
if (ext != "yaml" && ext != "yml") return;

final data = File.getContent('$dir/$name');
var newData = matchImport.map(data, reg -> {
final spaces = reg.matched(1);
final path = reg.matched(2);
final template = File.getContent('./$path');
final lines = template.split("\n");
for (i in 0...lines.length) lines[i] = spaces + lines[i];
lines.join("\n");
});

if (!matchRunnable.match(newData)) return;
final first = "# DO NOT EDIT. Generated from /extra/github-actions\n";
newData = first + newData;
final relativeDir = dir.replace(folder, "");
File.saveContent('$outFolder$relativeDir/$name', newData);
});
}

static function iterFolderItems(dir:String, func:(dir:String, name:String)->Void):Void {
for (name in FileSystem.readDirectory(dir)) {
if (FileSystem.isDirectory(name)) iterFolderItems('$dir/$name', func);
func(dir, name);
}
}

}
45 changes: 45 additions & 0 deletions extra/github-actions/build-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
- name: Install dependencies
run: |
set -ex
sudo add-apt-repository ppa:avsm/ppa -y # provides OPAM 2
sudo add-apt-repository ppa:haxe/ocaml -y # provides newer version of mbedtls
sudo apt-get update -qqy
sudo apt-get install -qqy ocaml-nox camlp5 opam libpcre3-dev zlib1g-dev libgtk2.0-dev libmbedtls-dev ninja-build neko neko-dev
- name: Install OCaml libraries
run: |
set -ex
opam init # --disable-sandboxing
opam update
opam pin add haxe . --no-action
opam install haxe --deps-only
opam list
ocamlopt -v
- name: Build Haxe
run: |
set -ex
eval $(opam env)
opam config exec -- make -s -j`nproc` STATICLINK=1 haxe
opam config exec -- make -s haxelib
make -s package_unix
ls -l out
ldd -v ./haxe
ldd -v ./haxelib
- name: Build xmldoc
run: |
set -ex
make -s xmldoc
cat >extra/doc/info.json <<EOL
{
"commit": "$GITHUB_SHA",
"branch": "$GITHUB_REF"
}
EOL
- name: Upload artifact
uses: actions/[email protected]
with:
name: linuxBinaries
path: out
33 changes: 33 additions & 0 deletions extra/github-actions/build-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
- name: Install dependencies
run: |
set -ex
brew update
brew unlink python@2
brew bundle --file=tests/Brewfile --no-upgrade
- name: Install OCaml libraries
run: |
set -ex
opam init # --disable-sandboxing
opam update
opam pin add haxe . --no-action
opam install haxe --deps-only
opam list
ocamlopt -v
- name: Build Haxe
run: |
set -ex
eval $(opam env)
opam config exec -- make -s -j`sysctl -n hw.ncpu` STATICLINK=1 "LIB_PARAMS=/usr/local/opt/zlib/lib/libz.a /usr/local/lib/libpcre.a /usr/local/lib/libmbedtls.a /usr/local/lib/libmbedcrypto.a /usr/local/lib/libmbedx509.a -cclib '-framework Security -framework CoreFoundation'" haxe
opam config exec -- make -s haxelib
make -s package_unix
ls -l out
otool -L ./haxe
otool -L ./haxelib
- name: Upload artifact
uses: actions/[email protected]
with:
name: macBinaries
path: out
50 changes: 50 additions & 0 deletions extra/github-actions/build-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
- name: choco install nsis
shell: pwsh
run: choco install --no-progress nsis.portable --version 3.02 -y
- name: choco install things
shell: pwsh
run: choco install --no-progress curl wget 7zip.portable -y
- name: Prepend Chocolatey path
shell: pwsh
run: Write-Host "::add-path::C:\ProgramData\chocolatey\bin"

- name: Install OCaml and OCaml libraries
shell: pwsh
run: |
Set-PSDebug -Trace 1
curl.exe -fsSL -o cygwin-setup.exe --retry 3 $($env:CYGWIN_SETUP)
Start-Process -FilePath "cygwin-setup.exe" -ArgumentList "-B -q -R $($env:CYG_ROOT) -l C:/tmp -s $($env:CYG_MIRROR) -P default -P make -P git -P zlib-devel -P rsync -P patch -P diffutils -P curl -P unzip -P tar -P m4 -P perl -P libpcre-devel -P mbedtls-devel -P mingw64-$($env:MINGW_ARCH)-zlib -P mingw64-$($env:MINGW_ARCH)-gcc-core -P mingw64-$($env:MINGW_ARCH)-pcre" -Wait
curl.exe -fsSL -o "opam.tar.xz" --retry 3 https://github.com/fdopen/opam-repository-mingw/releases/download/0.0.0.2/opam$($env:ARCH).tar.xz
curl.exe -fsSL -o "libmbedtls.tar.xz" --retry 3 https://github.com/Simn/mingw64-mbedtls/releases/download/2.16.3/mingw64-$($env:MINGW_ARCH)-mbedtls-2.16.3-1.tar.xz
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'echo "$OLDPWD"')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && tar -C / -xvf libmbedtls.tar.xz')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && tar -xf opam.tar.xz')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && bash opam${ARCH}/install.sh')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'opam init mingw "https://github.com/fdopen/opam-repository-mingw.git#opam2" --comp 4.07.0+mingw${ARCH}c --switch 4.07.0+mingw${ARCH}c --auto-setup --yes 2>&1')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'opam update --yes 2>&1')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam pin add haxe . --kind=path --no-action --yes 2>&1')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'opam install haxe --deps-only --yes 2>&1')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'opam list')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'ocamlopt -v')
- name: Expose mingw dll files
shell: pwsh
run: Write-Host "::add-path::${env:CYG_ROOT}/usr/$($env:MINGW_ARCH)-w64-mingw32/sys-root/mingw/bin"

- name: Build Haxe
shell: pwsh
run: |
Set-PSDebug -Trace 1
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -s -f Makefile.win -j`nproc` haxe 2>&1')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -s -f Makefile.win haxelib 2>&1')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -f Makefile.win echo_package_files package_bin package_installer_win package_choco 2>&1')
dir out
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && cygcheck ./haxe.exe')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && cygcheck ./haxelib.exe')
& "$($env:CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && ls ./out')
- name: Upload artifact
uses: actions/[email protected]
with:
name: win${{env.ARCH}}Binaries
path: out
2 changes: 2 additions & 0 deletions extra/github-actions/build.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--main Main
--interp
11 changes: 11 additions & 0 deletions extra/github-actions/install-neko-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- name: Install Neko using apt-get (Linux)
if: (startsWith(env.PLATFORM, 'linux'))
run: |
set -ex
sudo add-apt-repository ppa:haxe/snapshots -y
sudo apt-get update -qqy
sudo apt-get install -qqy neko
- name: Print Neko version
run: neko -version 2>&1

10 changes: 10 additions & 0 deletions extra/github-actions/install-neko-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- name: Install Neko using homebrew (Mac)
if: (startsWith(env.PLATFORM, 'mac'))
run: |
set -ex
HOMEBREW_NO_AUTO_UPDATE=1
brew install neko
- name: Print Neko version
run: neko -version 2>&1

15 changes: 15 additions & 0 deletions extra/github-actions/install-neko-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- name: Install Neko using snapshot from S3 (Windows)
if: startsWith(env.PLATFORM, 'windows')
shell: pwsh
run: |
$DOWNLOADDIR="./temp"
new-item -Name $DOWNLOADDIR -ItemType directory
Invoke-WebRequest https://build.haxe.org/builds/neko/$env:PLATFORM/neko_latest.zip -OutFile $DOWNLOADDIR/neko_latest.zip
Expand-Archive $DOWNLOADDIR/neko_latest.zip -DestinationPath $DOWNLOADDIR
$NEKOPATH = Get-ChildItem $DOWNLOADDIR/neko-*-*
Write-Host "::add-path::$NEKOPATH"
Write-Host "::set-env name=NEKOPATH::$NEKOPATH"
- name: Print Neko version
run: neko -version 2>&1

46 changes: 46 additions & 0 deletions extra/github-actions/test-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
- name: Setup Haxe
run: |
# mkdir ./linuxBinaries
# curl -sSL https://build.haxe.org/builds/haxe/linux64/haxe_latest.tar.gz -o ./linuxBinaries/haxe_bin.tar.gz
sudo apt install -qqy libmbedtls-dev
set -ex
tar -xf linuxBinaries/*_bin.tar.gz -C linuxBinaries --strip-components=1
sudo mkdir -p /usr/local/bin/
sudo mkdir -p /usr/local/share/haxe/
sudo ln -s `pwd`/linuxBinaries/haxe /usr/local/bin/haxe
sudo ln -s `pwd`/linuxBinaries/haxelib /usr/local/bin/haxelib
sudo ln -s `pwd`/linuxBinaries/std /usr/local/share/haxe/std
- name: Print Haxe version
run: haxe -version

- name: Setup haxelib
run: |
set -ex
mkdir ~/haxelib
haxelib setup ~/haxelib
- name: Install apt packages
if: matrix.APT_PACKAGES
run: |
set -ex
sudo apt update -qqy
sudo apt install -qqy ${{matrix.APT_PACKAGES}}
- name: Flash setup
if: matrix.target == 'flash9'
run: export DISPLAY=:99.0

- name: Test
if: success() && !(matrix.SAUCE && matrix.SAUCE_ACCESS_KEY)
run: haxe RunCi.hxml
working-directory: ${{github.workspace}}/tests

- name: Test (with SauceLabs)
if: matrix.target == 'js' && success() && matrix.SAUCE && matrix.SAUCE_ACCESS_KEY
run: haxe RunCi.hxml
working-directory: ${{github.workspace}}/tests
env:
SAUCE_ACCESS_KEY: matrix.SAUCE_ACCESS_KEY
32 changes: 32 additions & 0 deletions extra/github-actions/test-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
- name: Setup Haxe
run: |
# mkdir ./macBinaries
# curl -sSL https://build.haxe.org/builds/haxe/mac/haxe_latest.tar.gz -o ./macBinaries/haxe_bin.tar.gz
set -ex
tar -xf macBinaries/*_bin.tar.gz -C macBinaries --strip-components=1
sudo mkdir -p /usr/local/bin/
sudo mkdir -p /usr/local/share/haxe/
sudo ln -s `pwd`/macBinaries/haxe /usr/local/bin/haxe
sudo ln -s `pwd`/macBinaries/haxelib /usr/local/bin/haxelib
sudo ln -s `pwd`/macBinaries/std /usr/local/share/haxe/std
- name: Print Haxe version
run: haxe -version

- name: Setup haxelib
run: |
set -ex
mkdir ~/haxelib
haxelib setup ~/haxelib
- name: Install homebrew packages
if: matrix.BREW_PACKAGES
run: brew install ${{matrix.BREW_PACKAGES}}

- name: Test
run: |
# disable invalid Unicode filenames on APFS
echo "" > sys/compile-fs.hxml
haxe RunCi.hxml
working-directory: ${{github.workspace}}/tests
48 changes: 48 additions & 0 deletions extra/github-actions/test-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# - name: Quick test
# shell: pwsh
# run: |
# $DOWNLOADDIR="./win$($env:ARCH)Binaries"
# new-item -Name $DOWNLOADDIR -ItemType directory
# Invoke-WebRequest https://build.haxe.org/builds/haxe/$env:PLATFORM/haxe_latest.zip -OutFile $DOWNLOADDIR/haxe_bin.zip

- name: Setup Haxe
shell: pwsh
run: |
$DOWNLOADDIR="./win$($env:ARCH)Binaries"
Expand-Archive $DOWNLOADDIR/*_bin.zip -DestinationPath $DOWNLOADDIR
Set-PSDebug -Trace 1
$HAXEPATH = Get-ChildItem $DOWNLOADDIR/haxe_*_* -Directory
Write-Host "::add-path::$HAXEPATH"
Write-Host "::set-env name=HAXELIB_ROOT::$HAXEPATH\lib"
- name: Print Haxe version
shell: pwsh
run: haxe -version

- name: "Make Python 3 be available as python3 in the cmdline"
shell: pwsh
run: |
Set-PSDebug -Trace 1
$pypath = python -c "import sys; print(sys.executable)"
$py3path = $pypath.replace("python.exe","python3.exe")
cmd /c mklink $py3path $pypath
python3 -V
- name: Install hererocks
if: matrix.target == 'lua'
shell: cmd
run: |
pip install hererocks
hererocks lua53 -l5.3 -rlatest
call lua53/bin/activate
- name: Setup haxelib
shell: pwsh
run: |
mkdir "$env:HAXELIB_ROOT"
haxelib setup "$env:HAXELIB_ROOT"
- name: Test
shell: pwsh
run: haxe RunCi.hxml
working-directory: ${{github.workspace}}/tests
Loading

0 comments on commit efbd40b

Please sign in to comment.