Skip to content

Commit

Permalink
refactor(ci): mutualise more code inside composite actions
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperFola committed Mar 22, 2024
1 parent d46fafa commit dbd60bb
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 138 deletions.
63 changes: 21 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,65 +69,44 @@ jobs:
matrix:
config:
- {
os: ubuntu-latest, name: "Ubuntu Clang 15", cc: "clang-15", cxx: "clang++-15",
artifact: "ubuntu-clang-15", sanitizers: "Off", preconfigure: ""
os: ubuntu-latest, name: "Ubuntu Clang 15",
compiler: clang, compiler_version: 15, sanitizers: "Off",
artifact: "ubuntu-clang-15"
}
- {
os: ubuntu-latest, name: "Ubuntu Clang 15 (valgrind)", cc: "clang-15", cxx: "clang++-15",
artifact: "ubuntu-clang-valgrind", sanitizers: "Off", preconfigure: ""
os: ubuntu-latest, name: "Ubuntu Clang 15 (valgrind)",
compiler: clang, compiler_version: 15, sanitizers: "Off",
artifact: "ubuntu-clang-valgrind"
}
- {
os: ubuntu-latest, name: "Ubuntu GCC 13", cc: "gcc-13", cxx: "g++-13",
artifact: "ubuntu-gcc-13", sanitizers: "Off", preconfigure: ""
os: ubuntu-latest, name: "Ubuntu GCC 13",
compiler: gcc, compiler_version: 13, sanitizers: "Off",
artifact: "ubuntu-gcc-13"
}
- {
os: windows-latest, name: "Windows VS 2022", cc: "cl", cxx: "cl",
artifact: "windows-msvc-22", sanitizers: "On", preconfigure: ""
os: windows-latest, name: "Windows VS 2022",
compiler: msvc, compiler_version: "", sanitizers: "On",
artifact: "windows-msvc-22"
}
- {
os: macos-latest, name: "MacOS Clang 14", cc: "clang", cxx: "clang++",
os: macos-latest, name: "MacOS Clang 14",
artifact: "macos-clang-14",
sanitizers: "On", preconfigure: "export OPENSSL_ROOT_DIR=/usr/local/opt/openssl/"
compiler: clang, compiler_version: 14, sanitizers: "On"
}

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup compilers
- name: Setup compilers, dependencies, project and build
uses: ./.github/workflows/setup-compilers

- name: Setup dependencies
uses: ./.github/workflows/setup-deps

- name: Configure CMake Ark
if: ${{ !startsWith(matrix.config.name, 'Windows') }}
shell: bash
run: |
${{ matrix.config.preconfigure }}
cmake -Bbuild \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_C_COMPILER=${{ matrix.config.cc }} \
-DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} \
-DARK_SANITIZERS=${{ matrix.config.sanitizers }} \
-DARK_BUILD_EXE=On -DARK_BUILD_MODULES=On -DARK_MOD_ALL=Off -DARK_TESTS=On
- name: Configure CMake Ark
if: startsWith(matrix.config.name, 'Windows')
shell: bash
run: |
cmake -Bbuild \
-G "Visual Studio 17 2022" -T v143 \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DARK_SANITIZERS=${{ matrix.config.sanitizers }} \
-DARK_BUILD_EXE=On -DARK_BUILD_MODULES=On -DARK_MOD_ALL=Off -DARK_TESTS=On
#-DSQLite3_INCLUDE_DIR=$(pwd)/sqlite_code/sqlite-amalgamation-${SQLITE_VERSION}
#-DSQLite3_LIBRARY=$(pwd)/sqlite_lib/sqlite3.lib
- name: Build ArkScript
shell: bash
run: cmake --build build --config $BUILD_TYPE
with:
os_name: ${{ matrix.config.os }}
compiler: ${{ matrix.config.compiler }}
compiler_version: ${{ matrix.config.compiler_version }}
sanitizers: ${{ matrix.config.sanitizers }}
with_deps: true

- name: Organize files for upload
shell: bash
Expand Down
91 changes: 23 additions & 68 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,84 +19,39 @@ jobs:
matrix:
config:
- {
os: ubuntu-latest, name: "Ubuntu Clang 15", cc: "clang-15", cxx: "clang++-15",
artifact: "ubuntu-clang-15", preconfigure: ""
os: ubuntu-latest, name: "Ubuntu Clang 15",
compiler: clang, compiler_version: 15,
artifact: "ubuntu-clang-15"
}
- {
os: ubuntu-latest, name: "Ubuntu GCC 13", cc: "gcc-13", cxx: "g++-13",
artifact: "ubuntu-gcc-13", preconfigure: ""
os: ubuntu-latest, name: "Ubuntu GCC 13",
compiler: gcc, compiler_version: 13,
artifact: "ubuntu-gcc-13"
}
- {
os: windows-latest, name: "Windows VS 2019", cc: "cl", cxx: "cl",
artifact: "windows-msvc-19",
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
preconfigure: ""
os: windows-latest, name: "Windows VS 2022",
compiler: msvc, compiler_version: "",
artifact: "windows-msvc-22"
}
- {
os: macos-latest, name: "MacOS Clang 14", cc: "clang", cxx: "clang++",
os: macos-latest, name: "MacOS Clang 14",
artifact: "macos-clang-14",
preconfigure: "export OPENSSL_ROOT_DIR=/usr/local/opt/openssl/"
compiler: clang, compiler_version: 14,
}

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Update GNU compilers
if: startsWith(matrix.config.name, 'Ubuntu') && startsWith(matrix.config.cc, 'gcc')
shell: bash
run: |
sudo apt-add-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get -yq install ${{ matrix.config.cc }} ${{ matrix.config.cxx }}
- name: Update LLVM compilers
if: startsWith(matrix.config.name, 'Ubuntu') && startsWith(matrix.config.cc, 'clang')
shell: bash
run: |
version=`echo ${{ matrix.config.cc }} | cut -c 7-`
sudo apt-get install -y clang-${version} lld-${version} libc++-${version}-dev libc++abi-${version}-dev clang-tools-${version}
- name: Install MacOS dependencies
if: startsWith(matrix.config.name, 'MacOS')
shell: bash
run: env HOMEBREW_NO_AUTO_UPDATE=1 brew install openssl

- uses: ilammy/msvc-dev-cmd@v1
if: startsWith(matrix.config.name, 'Windows')

- name: Download Windows dependencies
if: startsWith(matrix.config.name, 'Windows')
shell: pwsh
run: |
Invoke-RestMethod -Uri https://www.sqlite.org/2022/sqlite-dll-win64-x64-${Env:SQLITE_VERSION}.zip -OutFile sqlite.zip
Invoke-RestMethod -Uri https://www.sqlite.org/2022/sqlite-amalgamation-${Env:SQLITE_VERSION}.zip -OutFile amalgation.zip
Expand-Archive sqlite.zip -DestinationPath sqlite_lib
Expand-Archive amalgation.zip -DestinationPath sqlite_code
cd sqlite_lib
lib /DEF:sqlite3.def /OUT:sqlite3.lib /MACHINE:x64
- name: Configure CMake Ark
shell: bash
run: |
${{ matrix.config.preconfigure }}
cmake -Bbuild \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_C_COMPILER=${{ matrix.config.cc }} \
-DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} \
-DARK_BUILD_EXE=On -DARK_BUILD_MODULES=On -DARK_MOD_ALL=On
- name: Add SQLite deps
if: startsWith(matrix.config.name, 'Windows')
shell: bash
run: |
cmake -Bbuild \
-DSQLite3_INCLUDE_DIR=$(pwd)/sqlite_code/sqlite-amalgamation-${SQLITE_VERSION} \
-DSQLite3_LIBRARY=$(pwd)/sqlite_lib/sqlite3.lib
- name: Build ArkScript
shell: bash
run: cmake --build build --config $BUILD_TYPE
- name: Setup compilers, dependencies, project and build
uses: ./.github/workflows/setup-compilers
with:
os_name: ${{ matrix.config.os }}
compiler: ${{ matrix.config.compiler }}
compiler_version: ${{ matrix.config.compiler_version }}
sanitizers: 'Off'
with_deps: true

- name: Organize files for upload
if: startsWith(matrix.config.name, 'Ubuntu') || startsWith(matrix.config.name, 'MacOS')
Expand Down Expand Up @@ -160,8 +115,8 @@ jobs:
- name: Download artifact Windows MSVC 19
uses: actions/download-artifact@v3
with:
name: windows-msvc-19
path: ark-windows-msvc-19
name: windows-msvc-22
path: ark-windows-msvc-22

- name: Download artifact MacOS Clang
uses: actions/download-artifact@v3
Expand Down Expand Up @@ -236,8 +191,8 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./windows-msvc-19.zip
asset_name: windows-msvc-19.zip
asset_path: ./windows-msvc-22.zip
asset_name: windows-msvc-22.zip
asset_content_type: application/zip

- name: Upload artifact
Expand Down
93 changes: 86 additions & 7 deletions .github/workflows/setup-compilers/action.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,101 @@
---
name: "Update compilers"
inputs:
os_name:
description: 'OS name the CI runs on ; Ubuntu|Windows|MacOS'
required: true
compiler:
description: 'mscv|gcc|clang'
required: true
compiler_version:
description: 'version of the compiler'
required: true
sanitizers:
description: 'On|Off'
default: 'Off'
with_deps:
description: 'Download and configure dependencies or not (false|true)'
default: 'false'

runs:
using: "composite"
steps:
- name: Detect compilers
if: ${{ !startsWith(inputs.os_name, 'windows') }}
id: compilers
shell: bash
run: |
if [[ '${{ startsWith(inputs.os_name, 'macos') }}' == 'true' ]]; then
echo "cc=${{ inputs.compiler }}" >> $GITHUB_OUTPUT
echo "cxx=${{ inputs.compiler }}++" >> $GITHUB_OUTPUT
elif [[ '${{ inputs.compiler }}' == 'clang' ]]; then
echo "cc=clang-${{ inputs.compiler_version }}" >> $GITHUB_OUTPUT
echo "cxx=clang++-${{ inputs.compiler_version }}" >> $GITHUB_OUTPUT
elif [[ '${{ inputs.compiler }}' == 'gcc' ]]; then
echo "cc=gcc-${{ inputs.compiler_version }}" >> $GITHUB_OUTPUT
echo "cxx=g++-${{ inputs.compiler_version }}" >> $GITHUB_OUTPUT
fi
- name: Update GNU compilers
if: startsWith(matrix.config.name, 'Ubuntu GCC')
if: startsWith(inputs.os_name, 'ubuntu') && inputs.compiler == 'gcc'
shell: bash
run: |
sudo apt-add-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get -yq install ${{ matrix.config.cc }} ${{ matrix.config.cxx }}
sudo apt-get -yq install gcc-${{ inputs.compiler_version }} g++-${{ inputs.compiler_version }}
- name: Update LLVM compilers
if: startsWith(matrix.config.name, 'Ubuntu Clang')
if: startsWith(inputs.os_name, 'ubuntu') && inputs.compiler == 'clang'
shell: bash
run: |
version=`echo ${{ matrix.config.cc }} | cut -c 7-`
sudo apt-get install -y clang-${version} lld-${version} libc++-${version}-dev libc++abi-${version}-dev clang-tools-${version}
sudo apt-get install -y clang-${{ inputs.compiler_version }} lld-${{ inputs.compiler_version }} \
libc++-${{ inputs.compiler_version }}-dev libc++abi-${{ inputs.compiler_version }}-dev \
clang-tools-${{ inputs.compiler_version }}
- name: Setup Windows environment
uses: ilammy/msvc-dev-cmd@v1
if: startsWith(inputs.os_name, 'windows')

- uses: ilammy/msvc-dev-cmd@v1
if: startsWith(matrix.config.name, 'Windows')
- name: Install MacOS dependencies
if: startsWith(inputs.os_name, 'macos') && inputs.with_deps == 'true'
shell: bash
run: env HOMEBREW_NO_AUTO_UPDATE=1 brew install openssl

- name: Install Windows dependencies
if: startsWith(inputs.os_name, 'windows') && inputs.with_deps == 'true'
shell: pwsh
run: |
Invoke-RestMethod -Uri https://www.sqlite.org/2022/sqlite-dll-win64-x64-${Env:SQLITE_VERSION}.zip -OutFile sqlite.zip
Invoke-RestMethod -Uri https://www.sqlite.org/2022/sqlite-amalgamation-${Env:SQLITE_VERSION}.zip -OutFile amalgation.zip
Expand-Archive sqlite.zip -DestinationPath sqlite_lib
Expand-Archive amalgation.zip -DestinationPath sqlite_code
cd sqlite_lib
lib /DEF:sqlite3.def /OUT:sqlite3.lib /MACHINE:x64
- name: CMake Ark
if: ${{ !startsWith(inputs.os_name, 'windows') }}
shell: bash
run: |
if [[ '${{ startsWith(inputs.os_name, 'macos') }}' == 'true' ]]; then
export OPENSSL_ROOT_DIR=/usr/local/opt/openssl/
fi
cmake -Bbuild \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DCMAKE_C_COMPILER=${{ steps.compilers.outputs.cc }} \
-DCMAKE_CXX_COMPILER=${{ steps.compilers.outputs.cxx }} \
-DARK_SANITIZERS=${{ inputs.sanitizers }} \
-DARK_BUILD_EXE=On -DARK_BUILD_MODULES=On -DARK_MOD_ALL=Off -DARK_TESTS=On
cmake --build build --config $BUILD_TYPE -- -j $(nproc)
- name: Configure CMake Ark
if: startsWith(inputs.os_name, 'windows')
shell: bash
run: |
if [[ '${{ inputs.with_deps }}' == 'true' ]]; then
additional_args="-DSQLite3_INCLUDE_DIR=$(pwd)/sqlite_code/sqlite-amalgamation-${SQLITE_VERSION} -DSQLite3_LIBRARY=$(pwd)/sqlite_lib/sqlite3.lib"
fi
cmake -Bbuild \
-G "Visual Studio 17 2022" -T v143 \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DARK_SANITIZERS=${{ matrix.config.sanitizers }} \
-DARK_BUILD_EXE=On -DARK_BUILD_MODULES=On -DARK_MOD_ALL=Off -DARK_TESTS=On $additional_args
cmake --build build --config $BUILD_TYPE
21 changes: 0 additions & 21 deletions .github/workflows/setup-deps/action.yaml

This file was deleted.

0 comments on commit dbd60bb

Please sign in to comment.