From 21d776dfc031d63ca16e506986ce78356ed90290 Mon Sep 17 00:00:00 2001 From: caiowakamatsu Date: Thu, 4 Jun 2026 22:55:36 -0300 Subject: [PATCH] move to gitea workflow folder --- .gitea/ISSUE_TEMPLATE/bug_report.md | 40 ++ .gitea/ISSUE_TEMPLATE/feature_request.md | 19 + .gitea/actions/setup-pixi/action.yml | 20 + .gitea/workflows/benchmark.yml | 44 +++ .gitea/workflows/build-llvm.yml | 446 +++++++++++++++++++++++ .gitea/workflows/check-format.yml | 40 ++ .gitea/workflows/deploy-docs.yml | 30 ++ .gitea/workflows/main.yml | 137 +++++++ .gitea/workflows/publish-clice.yml | 100 +++++ .gitea/workflows/publish-vscode.yml | 38 ++ .gitea/workflows/test-cmake.yml | 170 +++++++++ .gitea/workflows/upload-llvm.yml | 38 ++ 12 files changed, 1122 insertions(+) create mode 100644 .gitea/ISSUE_TEMPLATE/bug_report.md create mode 100644 .gitea/ISSUE_TEMPLATE/feature_request.md create mode 100644 .gitea/actions/setup-pixi/action.yml create mode 100644 .gitea/workflows/benchmark.yml create mode 100644 .gitea/workflows/build-llvm.yml create mode 100644 .gitea/workflows/check-format.yml create mode 100644 .gitea/workflows/deploy-docs.yml create mode 100644 .gitea/workflows/main.yml create mode 100644 .gitea/workflows/publish-clice.yml create mode 100644 .gitea/workflows/publish-vscode.yml create mode 100644 .gitea/workflows/test-cmake.yml create mode 100644 .gitea/workflows/upload-llvm.yml diff --git a/.gitea/ISSUE_TEMPLATE/bug_report.md b/.gitea/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..9b77ea71 --- /dev/null +++ b/.gitea/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,40 @@ +--- +name: Bug report +about: Create a report to help us improve +title: "" +labels: "" +assignees: "" +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: + +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + +- OS: [e.g. iOS] +- Browser [e.g. chrome, safari] +- Version [e.g. 22] + +**Smartphone (please complete the following information):** + +- Device: [e.g. iPhone6] +- OS: [e.g. iOS8.1] +- Browser [e.g. stock browser, safari] +- Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.gitea/ISSUE_TEMPLATE/feature_request.md b/.gitea/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..2bc5d5f7 --- /dev/null +++ b/.gitea/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,19 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: "" +labels: "" +assignees: "" +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.gitea/actions/setup-pixi/action.yml b/.gitea/actions/setup-pixi/action.yml new file mode 100644 index 00000000..ea1b4ae2 --- /dev/null +++ b/.gitea/actions/setup-pixi/action.yml @@ -0,0 +1,20 @@ +name: "Setup Pixi" +description: "setup pixi" + +inputs: + environments: + description: "The pixi environments to install (e.g. default, docs, test)" + required: false + default: "default" + +runs: + using: "composite" + steps: + - name: Setup Pixi + uses: prefix-dev/setup-pixi@v0.9.3 + with: + pixi-version: v0.67.0 + environments: ${{ inputs.environments }} + activate-environment: true + cache: true + locked: true diff --git a/.gitea/workflows/benchmark.yml b/.gitea/workflows/benchmark.yml new file mode 100644 index 00000000..0ac4301e --- /dev/null +++ b/.gitea/workflows/benchmark.yml @@ -0,0 +1,44 @@ +name: benchmark + +on: + workflow_dispatch: + +jobs: + benchmark: + strategy: + fail-fast: false + matrix: + os: [ubuntu-24.04, macos-15, windows-2025] + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: ./.github/actions/setup-pixi + + - name: Build scan_benchmark + run: | + pixi run cmake-config RelWithDebInfo ON -- -DCLICE_ENABLE_BENCHMARK=ON + cmake --build build/RelWithDebInfo --target scan_benchmark + + - name: Clone LLVM + run: git clone --depth 1 https://github.com/llvm/llvm-project.git + + - name: Generate CDB + run: | + cmake -B llvm-build -G Ninja \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DCMAKE_TOOLCHAIN_FILE="$(pwd)/cmake/toolchain.cmake" \ + -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb;mlir;polly;flang;bolt" \ + -DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind" \ + llvm-project/llvm + + - name: Run benchmark + run: ./build/RelWithDebInfo/bin/scan_benchmark --runs 20 llvm-build/compile_commands.json + + - name: Stop sccache server + if: runner.os == 'Windows' + run: pixi run -- sccache --stop-server || true diff --git a/.gitea/workflows/build-llvm.yml b/.gitea/workflows/build-llvm.yml new file mode 100644 index 00000000..914a8131 --- /dev/null +++ b/.gitea/workflows/build-llvm.yml @@ -0,0 +1,446 @@ +name: build llvm + +on: + workflow_dispatch: + inputs: + llvm_version: + description: "LLVM version to build (e.g., 21.1.8)" + required: true + type: string + skip_upload: + description: "Skip upload and PR creation (build-only mode)" + required: false + type: boolean + default: false + skip_pr: + description: "Skip PR creation (upload only, no PR)" + required: false + type: boolean + default: false + pull_request: + # if you want to run this workflow, change the branch name to main, + # if you want to turn off it, change it to non existent branch. + branches: [main-turn-off] + +jobs: + build: + strategy: + fail-fast: false + matrix: + include: + # Native builds + - os: windows-2025 + llvm_mode: RelWithDebInfo + lto: OFF + - os: windows-2025 + llvm_mode: RelWithDebInfo + lto: ON + - os: ubuntu-24.04 + llvm_mode: Debug + lto: OFF + - os: ubuntu-24.04 + llvm_mode: RelWithDebInfo + lto: OFF + - os: ubuntu-24.04 + llvm_mode: RelWithDebInfo + lto: ON + - os: macos-15 + llvm_mode: Debug + lto: OFF + - os: macos-15 + llvm_mode: RelWithDebInfo + lto: OFF + - os: macos-15 + llvm_mode: RelWithDebInfo + lto: ON + + # Cross-compilation builds + # macOS x64 (from arm64 macos-15) + - os: macos-15 + llvm_mode: RelWithDebInfo + lto: OFF + target_triple: x86_64-apple-darwin + - os: macos-15 + llvm_mode: RelWithDebInfo + lto: ON + target_triple: x86_64-apple-darwin + + # Linux aarch64 (from x64 ubuntu-24.04) + - os: ubuntu-24.04 + llvm_mode: RelWithDebInfo + lto: OFF + target_triple: aarch64-linux-gnu + pixi_env: cross-linux-aarch64 + - os: ubuntu-24.04 + llvm_mode: RelWithDebInfo + lto: ON + target_triple: aarch64-linux-gnu + pixi_env: cross-linux-aarch64 + + # Windows arm64 (from x64 windows-2025) + - os: windows-2025 + llvm_mode: RelWithDebInfo + lto: OFF + target_triple: aarch64-pc-windows-msvc + pixi_env: cross-windows-arm64 + - os: windows-2025 + llvm_mode: RelWithDebInfo + lto: ON + target_triple: aarch64-pc-windows-msvc + pixi_env: cross-windows-arm64 + + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Free Disk Space + if: runner.os == 'Linux' + uses: jlumbroso/free-disk-space@main + + - name: Increase Swap Space + if: runner.os == 'Linux' + run: | + echo "===== Initial Status =====" + sudo swapon --show + free -h + + echo "===== Creating Swap File =====" + sudo swapoff -a + sudo fallocate -l 16G /mnt/swapfile + sudo chmod 600 /mnt/swapfile + sudo mkswap /mnt/swapfile + sudo swapon /mnt/swapfile + + echo "===== Final Status =====" + sudo swapon --show + free -h + df -h + + - uses: ./.github/actions/setup-pixi + with: + environments: ${{ matrix.pixi_env || 'package' }} + + - name: Clone llvm-project + shell: bash + run: | + VERSION="${{ inputs.llvm_version || '21.1.8' }}" + echo "Cloning LLVM ${VERSION}..." + git clone --branch "llvmorg-${VERSION}" --depth 1 https://github.com/llvm/llvm-project.git .llvm + + - name: Validate distribution components + shell: bash + run: | + python3 scripts/validate-llvm-components.py \ + --llvm-src=.llvm \ + --components-file=scripts/llvm-components.json + + - name: Build LLVM (install-distribution) + shell: bash + run: | + ENV="${{ matrix.pixi_env || 'package' }}" + EXTRA_ARGS="" + if [[ -n "${{ matrix.target_triple }}" ]]; then + EXTRA_ARGS="--target-triple=${{ matrix.target_triple }}" + fi + pixi run -e "$ENV" build-llvm \ + --llvm-src=.llvm \ + --mode="${{ matrix.llvm_mode }}" \ + --lto="${{ matrix.lto }}" \ + --build-dir=build \ + ${EXTRA_ARGS} + + - name: Build clice using installed LLVM + if: ${{ !matrix.target_triple }} + shell: bash + run: | + pixi run cmake-config ${{ matrix.llvm_mode }} ON -- \ + "-DCLICE_ENABLE_LTO=${{ matrix.lto }}" \ + "-DLLVM_INSTALL_PATH=.llvm/build-install" + pixi run cmake-build ${{ matrix.llvm_mode }} + + - name: Build clice using installed LLVM (cross-compile) + if: ${{ matrix.target_triple }} + shell: bash + run: | + ENV="${{ matrix.pixi_env || 'package' }}" + pixi run -e "$ENV" cmake-config ${{ matrix.llvm_mode }} ON -- \ + "-DCLICE_ENABLE_LTO=${{ matrix.lto }}" \ + "-DCLICE_TARGET_TRIPLE=${{ matrix.target_triple }}" \ + "-DLLVM_INSTALL_PATH=.llvm/build-install" + pixi run -e "$ENV" cmake-build ${{ matrix.llvm_mode }} + + - name: Verify cross-compiled binary architecture + if: ${{ matrix.target_triple && runner.os != 'Windows' }} + shell: bash + run: | + BINARY="build/${{ matrix.llvm_mode }}/bin/clice" + echo "Binary info:" + file "$BINARY" + case "${{ matrix.target_triple }}" in + aarch64-linux-gnu) file "$BINARY" | grep -q "aarch64" ;; + x86_64-apple-darwin) file "$BINARY" | grep -q "x86_64" ;; + esac + + - name: Upload cross-compiled clice for functional test + if: ${{ matrix.target_triple && matrix.lto == 'OFF' }} + uses: actions/upload-artifact@v4 + with: + name: cross-clice-${{ matrix.target_triple }}-${{ matrix.llvm_mode }} + path: | + build/${{ matrix.llvm_mode }}/bin/ + build/${{ matrix.llvm_mode }}/lib/ + if-no-files-found: error + retention-days: 1 + + - name: Run tests + if: ${{ !matrix.target_triple }} + shell: bash + run: pixi run test ${{ matrix.llvm_mode }} + + # Prune is only supported for native builds (requires linking clice to test). + # Cross-compiled targets reuse the native prune manifest of the same OS. + - name: Prune LLVM static libraries (Debug/RelWithDebInfo no LTO) + if: (!matrix.target_triple) && (matrix.llvm_mode == 'Debug' || (matrix.llvm_mode == 'RelWithDebInfo' && matrix.lto == 'OFF')) + shell: bash + run: | + MANIFEST="pruned-libs-${{ matrix.os }}.json" + echo "LLVM_PRUNED_MANIFEST=${MANIFEST}" >> "${GITHUB_ENV}" + python3 scripts/prune-llvm-bin.py \ + --action discover \ + --install-dir ".llvm/build-install/lib" \ + --build-dir "build/${{ matrix.llvm_mode }}" \ + --max-attempts 60 \ + --sleep-seconds 60 \ + --manifest "${MANIFEST}" + + - name: Upload pruned-libs manifest + if: (!matrix.target_triple) && matrix.llvm_mode == 'RelWithDebInfo' && matrix.lto == 'OFF' + uses: actions/upload-artifact@v4 + with: + name: llvm-pruned-libs-${{ matrix.os }} + path: ${{ env.LLVM_PRUNED_MANIFEST }} + if-no-files-found: error + compression-level: 0 + + - name: Apply pruned-libs manifest (RelWithDebInfo + LTO, native only) + if: (!matrix.target_triple) && matrix.llvm_mode == 'RelWithDebInfo' && matrix.lto == 'ON' + shell: bash + env: + GH_TOKEN: ${{ github.token }} + run: | + MANIFEST="pruned-libs-${{ matrix.os }}.json" + python3 scripts/prune-llvm-bin.py \ + --action apply \ + --manifest "${MANIFEST}" \ + --install-dir ".llvm/build-install/lib" \ + --build-dir "build/${{ matrix.llvm_mode }}" \ + --gh-run-id "${{ github.run_id }}" \ + --gh-artifact "llvm-pruned-libs-${{ matrix.os }}" \ + --gh-download-dir "artifacts" \ + --max-attempts 60 \ + --sleep-seconds 60 + + # For cross-compiled LTO builds, apply the native prune manifest. + # The unused library set is arch-independent (same API surface). + - name: Apply pruned-libs manifest (cross-compile + LTO) + if: matrix.target_triple && matrix.lto == 'ON' + shell: bash + env: + GH_TOKEN: ${{ github.token }} + run: | + MANIFEST="pruned-libs-${{ matrix.os }}.json" + python3 scripts/prune-llvm-bin.py \ + --action apply \ + --manifest "${MANIFEST}" \ + --install-dir ".llvm/build-install/lib" \ + --build-dir "build/${{ matrix.llvm_mode }}" \ + --gh-run-id "${{ github.run_id }}" \ + --gh-artifact "llvm-pruned-libs-${{ matrix.os }}" \ + --gh-download-dir "artifacts" \ + --max-attempts 60 \ + --sleep-seconds 60 + + - name: Package LLVM install directory + shell: bash + run: | + MODE_TAG="releasedbg" + if [[ "${{ matrix.llvm_mode }}" == "Debug" ]]; then + MODE_TAG="debug" + fi + + # Determine arch/platform/toolchain from target triple or runner OS + if [[ -n "${{ matrix.target_triple }}" ]]; then + case "${{ matrix.target_triple }}" in + x86_64-apple-darwin) + ARCH="x64"; PLATFORM="macos"; TOOLCHAIN="clang" ;; + aarch64-linux-gnu) + ARCH="aarch64"; PLATFORM="linux"; TOOLCHAIN="gnu" ;; + aarch64-pc-windows-msvc) + ARCH="aarch64"; PLATFORM="windows"; TOOLCHAIN="msvc" ;; + esac + else + ARCH="x64" + PLATFORM="linux" + TOOLCHAIN="gnu" + if [[ "${{ matrix.os }}" == windows-* ]]; then + PLATFORM="windows" + TOOLCHAIN="msvc" + elif [[ "${{ matrix.os }}" == macos-* ]]; then + ARCH="arm64" + PLATFORM="macos" + TOOLCHAIN="clang" + fi + fi + + SUFFIX="" + if [[ "${{ matrix.lto }}" == "ON" ]]; then + SUFFIX="-lto" + fi + if [[ "${{ matrix.llvm_mode }}" == "Debug" && "${{ matrix.os }}" != windows-* ]]; then + SUFFIX="${SUFFIX}-asan" + fi + + ARCHIVE="${ARCH}-${PLATFORM}-${TOOLCHAIN}-${MODE_TAG}${SUFFIX}.tar.xz" + + set -eo pipefail + tar -C .llvm -cf - build-install | xz -T0 -9 -c > "${ARCHIVE}" + echo "LLVM_INSTALL_ARCHIVE=${ARCHIVE}" >> "${GITHUB_ENV}" + + - name: Upload LLVM install artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.LLVM_INSTALL_ARCHIVE }} + path: ${{ env.LLVM_INSTALL_ARCHIVE }} + if-no-files-found: error + + test-cross: + needs: build + strategy: + fail-fast: false + matrix: + include: + - os: macos-15-intel + llvm_mode: RelWithDebInfo + target_triple: x86_64-apple-darwin + - os: ubuntu-24.04-arm + llvm_mode: RelWithDebInfo + target_triple: aarch64-linux-gnu + - os: windows-11-arm + llvm_mode: RelWithDebInfo + target_triple: aarch64-pc-windows-msvc + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: ./.github/actions/setup-pixi + with: + environments: test-run + + - name: Download cross-compiled clice + uses: actions/download-artifact@v4 + with: + name: cross-clice-${{ matrix.target_triple }}-${{ matrix.llvm_mode }} + path: build/${{ matrix.llvm_mode }}/ + + - name: Make binaries executable + if: runner.os != 'Windows' + run: chmod +x build/${{ matrix.llvm_mode }}/bin/* + + - name: Run tests + run: pixi run -e test-run test ${{ matrix.llvm_mode }} + + upload: + needs: build + if: ${{ !cancelled() && inputs.llvm_version && !inputs.skip_upload }} + runs-on: ubuntu-24.04 + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Download all build artifacts + env: + GH_TOKEN: ${{ github.token }} + run: scripts/download-llvm.sh "${{ github.run_id }}" + + - name: Upload to clice-llvm + env: + GH_TOKEN: ${{ secrets.UPLOAD_LLVM }} + TARGET_REPO: clice-io/clice-llvm + run: python3 scripts/upload-llvm.py "${{ inputs.llvm_version }}" "${TARGET_REPO}" "${{ github.run_id }}" + + - name: Save manifest for update-clice job + uses: actions/upload-artifact@v4 + with: + name: llvm-manifest-final + path: artifacts/llvm-manifest.json + if-no-files-found: error + compression-level: 0 + + update-clice: + needs: upload + if: ${{ !inputs.skip_pr }} + runs-on: ubuntu-24.04 + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + + - name: Download manifest + uses: actions/download-artifact@v4 + with: + name: llvm-manifest-final + path: . + + - name: Update manifest and version + run: | + python3 scripts/update-llvm-version.py \ + --version "${{ inputs.llvm_version }}" \ + --manifest-src llvm-manifest.json \ + --manifest-dest config/llvm-manifest.json \ + --package-cmake cmake/package.cmake + + - name: Create or update PR + env: + GH_TOKEN: ${{ github.token }} + run: | + VERSION="${{ inputs.llvm_version }}" + BRANCH="chore/update-llvm-${VERSION}" + RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + RELEASE_URL="https://github.com/clice-io/clice-llvm/releases/tag/${VERSION}" + + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git checkout -b "${BRANCH}" + git add config/llvm-manifest.json cmake/package.cmake + git commit -m "chore: update LLVM to ${VERSION}" + git push --force-with-lease origin "${BRANCH}" + + # Check if PR already exists for this branch + EXISTING_PR=$(gh pr list --head "${BRANCH}" --json number --jq '.[0].number // empty') + + BODY="$(cat < Auto-generated by build-llvm workflow + EOF + )" + + if [[ -n "${EXISTING_PR}" ]]; then + echo "Updating existing PR #${EXISTING_PR}" + gh pr edit "${EXISTING_PR}" --body "${BODY}" + else + gh pr create \ + --title "chore: update LLVM to ${VERSION}" \ + --body "${BODY}" \ + --base main + fi diff --git a/.gitea/workflows/check-format.yml b/.gitea/workflows/check-format.yml new file mode 100644 index 00000000..ffc9a52e --- /dev/null +++ b/.gitea/workflows/check-format.yml @@ -0,0 +1,40 @@ +name: format + +on: + workflow_call: + +jobs: + check-format: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - uses: ./.github/actions/setup-pixi + with: + environments: format + + - name: Validate update-llvm-version.py can still patch package.cmake + run: | + python3 scripts/update-llvm-version.py --check \ + --manifest-dest config/llvm-manifest.json \ + --package-cmake cmake/package.cmake + + - name: Run formatter + run: pixi run format + continue-on-error: true + + - name: Auto correct + uses: huacnlee/autocorrect-action@v2 + with: + args: --lint ./docs + continue-on-error: true + + - name: Check diff + run: | + if ! git diff --quiet; then + echo "::error::Formatting changes detected. Please run 'pixi run format' and commit the result." + git --no-pager diff --stat + git --no-pager diff + exit 1 + fi diff --git a/.gitea/workflows/deploy-docs.yml b/.gitea/workflows/deploy-docs.yml new file mode 100644 index 00000000..28a49fb9 --- /dev/null +++ b/.gitea/workflows/deploy-docs.yml @@ -0,0 +1,30 @@ +name: deploy + +on: + workflow_call: + +jobs: + deploy-docs: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: ./.github/actions/setup-pixi + with: + environments: node + + - name: Build docs + run: pixi run build-docs + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v4 + if: github.ref == 'refs/heads/main' + with: + personal_token: ${{ secrets.PUBLISH_DOCS }} + external_repository: clice-io/docs + publish_dir: ./docs/.vitepress/dist + destination_dir: clice + keep_files: true diff --git a/.gitea/workflows/main.yml b/.gitea/workflows/main.yml new file mode 100644 index 00000000..db0d7e21 --- /dev/null +++ b/.gitea/workflows/main.yml @@ -0,0 +1,137 @@ +name: main + +on: + push: + branches: [main] + tags: ["v*"] + pull_request: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +jobs: + changes: + if: ${{ !startsWith(github.ref, 'refs/tags/') }} + runs-on: ubuntu-latest + permissions: + pull-requests: read + outputs: + format: ${{ steps.filter.outputs.format }} + docs: ${{ steps.filter.outputs.docs }} + clice: ${{ steps.filter.outputs.clice }} + vscode: ${{ steps.filter.outputs.vscode }} + cmake: ${{ steps.filter.outputs.cmake }} + + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + format: + - '**/*.{h,c,cpp,hpp,ts,js,lua,md,yml,yaml}' + docs: + - 'docs/**' + - '.github/workflows/deploy-docs.yml' + clice: + - 'src/**' + - 'include/**' + - 'CMakeLists.txt' + - '.github/workflows/publish-clice.yml' + vscode: + - 'editors/vscode/**' + - '.github/workflows/publish-vscode.yml' + cmake: + - 'CMakeLists.txt' + - 'src/**' + - 'include/**' + - 'tests/**' + - 'config/**' + - '.github/workflows/test-cmake.yml' + + conventional-commit: + if: ${{ !startsWith(github.ref, 'refs/tags/') }} + runs-on: ubuntu-latest + steps: + - name: Check conventional commit format + env: + IS_PR: ${{ github.event_name == 'pull_request' }} + PR_TITLE: ${{ github.event.pull_request.title }} + COMMIT_MSG: ${{ github.event.head_commit.message }} + run: | + pattern='^(feat|fix|refactor|chore|build|ci|docs|test|perf|style|revert)(\(.+\))?: .+' + if [[ "$IS_PR" == "true" ]]; then + subject="$PR_TITLE" + label="PR title" + else + subject=$(echo "$COMMIT_MSG" | head -n1) + label="Commit message" + fi + if [[ ! "$subject" =~ $pattern ]]; then + echo "::error::$label must follow conventional commit format: type(scope)?: description" + echo " Valid types: feat, fix, refactor, chore, build, ci, docs, test, perf, style, revert" + echo " Got: '$subject'" + exit 1 + fi + + format: + needs: changes + if: ${{ needs.changes.outputs.format == 'true' }} + uses: ./.github/workflows/check-format.yml + + deploy: + needs: changes + if: ${{ needs.changes.outputs.docs == 'true' }} + permissions: + contents: write + uses: ./.github/workflows/deploy-docs.yml + secrets: inherit + + # clice: + # needs: changes + # if: ${{ needs.changes.outputs.clice == 'true' }} + # uses: ./.github/workflows/publish-clice.yml + + vscode: + needs: changes + if: ${{ needs.changes.outputs.vscode == 'true' }} + uses: ./.github/workflows/publish-vscode.yml + + cmake: + needs: changes + if: ${{ needs.changes.outputs.cmake == 'true' }} + uses: ./.github/workflows/test-cmake.yml + + release-clice: + permissions: + contents: write + if: startsWith(github.ref, 'refs/tags/v') + uses: ./.github/workflows/publish-clice.yml + secrets: inherit + + release-vscode: + permissions: + contents: write + if: startsWith(github.ref, 'refs/tags/v') + uses: ./.github/workflows/publish-vscode.yml + secrets: inherit + + checks-passed: + if: ${{ always() && !startsWith(github.ref, 'refs/tags/') }} + needs: + - conventional-commit + - format + - deploy + # - clice + - vscode + - cmake + + runs-on: ubuntu-latest + steps: + - name: Check results + uses: re-actors/alls-green@release/v1 + with: + allowed-skips: conventional-commit,format,deploy,clice,vscode,cmake + jobs: ${{ toJSON(needs) }} diff --git a/.gitea/workflows/publish-clice.yml b/.gitea/workflows/publish-clice.yml new file mode 100644 index 00000000..663c2b1a --- /dev/null +++ b/.gitea/workflows/publish-clice.yml @@ -0,0 +1,100 @@ +name: clice + +on: + workflow_call: + +jobs: + publish-clice: + strategy: + fail-fast: false + matrix: + include: + # Native builds + - os: windows-2025 + artifact_name: clice.zip + asset_name: clice-x64-windows-msvc.zip + symbol_artifact_name: clice-symbol.zip + symbol_asset_name: clice-x64-windows-msvc-symbol.zip + + - os: ubuntu-24.04 + artifact_name: clice.tar.gz + asset_name: clice-x86_64-linux-gnu.tar.gz + symbol_artifact_name: clice-symbol.tar.gz + symbol_asset_name: clice-x86_64-linux-gnu-symbol.tar.gz + + - os: macos-15 + artifact_name: clice.tar.gz + asset_name: clice-arm64-macos-darwin.tar.gz + symbol_artifact_name: clice-symbol.tar.gz + symbol_asset_name: clice-arm64-macos-darwin-symbol.tar.gz + + # Cross-compilation builds + - os: macos-15 + target_triple: x86_64-apple-darwin + pixi_env: cross-macos-x64 + artifact_name: clice.tar.gz + asset_name: clice-x86_64-macos-darwin.tar.gz + symbol_artifact_name: clice-symbol.tar.gz + symbol_asset_name: clice-x86_64-macos-darwin-symbol.tar.gz + + - os: ubuntu-24.04 + target_triple: aarch64-linux-gnu + pixi_env: cross-linux-aarch64 + artifact_name: clice.tar.gz + asset_name: clice-aarch64-linux-gnu.tar.gz + symbol_artifact_name: clice-symbol.tar.gz + symbol_asset_name: clice-aarch64-linux-gnu-symbol.tar.gz + + - os: windows-2025 + target_triple: aarch64-pc-windows-msvc + pixi_env: cross-windows-arm64 + artifact_name: clice.zip + asset_name: clice-aarch64-windows-msvc.zip + symbol_artifact_name: clice-symbol.zip + symbol_asset_name: clice-aarch64-windows-msvc-symbol.zip + + runs-on: ${{ matrix.os }} + + defaults: + run: + shell: bash + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: ./.github/actions/setup-pixi + with: + environments: ${{ matrix.pixi_env || 'package' }} + + - name: Package (native) + if: ${{ !matrix.target_triple }} + run: pixi run package + + - name: Package (cross-compile) + if: ${{ matrix.target_triple }} + run: | + ENV="${{ matrix.pixi_env }}" + pixi run -e "$ENV" package-config -- \ + "-DCLICE_TARGET_TRIPLE=${{ matrix.target_triple }}" + pixi run -e "$ENV" cmake-build + + - name: Upload Main Package to Release + if: startsWith(github.ref, 'refs/tags/v') + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: build/RelWithDebInfo/${{ matrix.artifact_name }} + asset_name: ${{ matrix.asset_name }} + tag: ${{ github.ref }} + overwrite: true + + - name: Upload Symbol Package to Release + if: startsWith(github.ref, 'refs/tags/v') + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: build/RelWithDebInfo/${{ matrix.symbol_artifact_name }} + asset_name: ${{ matrix.symbol_asset_name }} + tag: ${{ github.ref }} + overwrite: true diff --git a/.gitea/workflows/publish-vscode.yml b/.gitea/workflows/publish-vscode.yml new file mode 100644 index 00000000..5443b079 --- /dev/null +++ b/.gitea/workflows/publish-vscode.yml @@ -0,0 +1,38 @@ +name: vscode + +on: + workflow_call: + +jobs: + publish-vscode: + runs-on: ubuntu-latest + defaults: + run: + working-directory: editors/vscode + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: ./.github/actions/setup-pixi + with: + environments: node + + - name: Publish and Package to Marketplace + env: + VSCE_PAT: ${{ secrets.VSCE_PAT }} + run: | + FLAG="${{ contains(github.ref_name, '-') && '--pre-release' || '' }}" + pixi run build-vscode $FLAG + + if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then + pixi run publish-vscode -p "$VSCE_PAT" $FLAG + fi + + - name: Upload .vsix to Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/v') + with: + files: "editors/vscode/*.vsix" + tag_name: ${{ github.ref }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitea/workflows/test-cmake.yml b/.gitea/workflows/test-cmake.yml new file mode 100644 index 00000000..6702130c --- /dev/null +++ b/.gitea/workflows/test-cmake.yml @@ -0,0 +1,170 @@ +name: cmake + +on: + workflow_call: + +env: + CCACHE_DIR: ${{ github.workspace }}/.cache/ccache + SCCACHE_DIR: ${{ github.workspace }}/.cache/sccache + CCACHE_BASEDIR: ${{ github.workspace }} + SCCACHE_BASEDIRS: ${{ github.workspace }} + CCACHE_COMPILERCHECK: content + CCACHE_MAXSIZE: 2G + SCCACHE_CACHE_SIZE: 2G + +jobs: + build: + strategy: + fail-fast: false + matrix: + include: + # Native builds + - os: windows-2025 + build_type: RelWithDebInfo + - os: ubuntu-24.04 + build_type: Debug + - os: ubuntu-24.04 + build_type: RelWithDebInfo + - os: macos-15 + build_type: Debug + - os: macos-15 + build_type: RelWithDebInfo + # Cross-compile (build only; tests run on native runners) + - os: macos-15 + build_type: RelWithDebInfo + target_triple: x86_64-apple-darwin + build_only: true + - os: ubuntu-24.04 + build_type: RelWithDebInfo + target_triple: aarch64-linux-gnu + build_only: true + pixi_env: cross-linux-aarch64 + - os: windows-2025 + build_type: RelWithDebInfo + target_triple: aarch64-pc-windows-msvc + build_only: true + pixi_env: cross-windows-arm64 + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: ./.github/actions/setup-pixi + with: + environments: ${{ matrix.pixi_env || 'default' }} + + - name: Restore compiler cache + uses: actions/cache@v4 + with: + path: ${{ runner.os == 'Windows' && '.cache/sccache' || '.cache/ccache' }} + key: ${{ runner.os }}-${{ matrix.build_type }}-${{ matrix.target_triple || 'native' }}-ccache-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-${{ matrix.build_type }}-${{ matrix.target_triple || 'native' }}-ccache- + + - name: Zero cache stats + run: | + ENV="${{ matrix.pixi_env || 'default' }}" + if [ "$RUNNER_OS" = "Windows" ]; then + pixi run -e "$ENV" -- sccache --stop-server || true + pixi run -e "$ENV" -- sccache --zero-stats || true + else + pixi run -e "$ENV" -- ccache --zero-stats || true + fi + shell: bash + + - name: Build (native) + if: ${{ !matrix.target_triple }} + run: pixi run build ${{ matrix.build_type }} ON + + - name: Build (cross-compile) + if: ${{ matrix.target_triple }} + shell: bash + run: | + ENV="${{ matrix.pixi_env || 'default' }}" + pixi run -e "$ENV" cmake-config ${{ matrix.build_type }} OFF -- \ + "-DCLICE_TARGET_TRIPLE=${{ matrix.target_triple }}" + pixi run -e "$ENV" cmake-build ${{ matrix.build_type }} + + - name: Upload cross-compiled binaries + if: ${{ matrix.build_only }} + uses: actions/upload-artifact@v4 + with: + name: cross-build-${{ matrix.target_triple }} + path: | + build/${{ matrix.build_type }}/bin/ + build/${{ matrix.build_type }}/lib/ + if-no-files-found: error + retention-days: 1 + + - name: Unit tests + if: ${{ !matrix.build_only }} + timeout-minutes: 5 + run: pixi run unit-test ${{ matrix.build_type }} + + - name: Integration tests + if: ${{ !matrix.build_only }} + timeout-minutes: 20 + run: pixi run integration-test ${{ matrix.build_type }} + + - name: Smoke tests + if: ${{ !matrix.build_only }} + timeout-minutes: 15 + run: pixi run smoke-test ${{ matrix.build_type }} + + - name: Print cache stats and stop server + if: always() + run: | + ENV="${{ matrix.pixi_env || 'default' }}" + if [ "$RUNNER_OS" = "Windows" ]; then + pixi run -e "$ENV" -- sccache --show-stats + pixi run -e "$ENV" -- sccache --stop-server || true + else + pixi run -e "$ENV" -- ccache --show-stats + fi + shell: bash + + test-cross: + needs: build + strategy: + fail-fast: false + matrix: + include: + - os: macos-15-intel + build_type: RelWithDebInfo + target_triple: x86_64-apple-darwin + - os: ubuntu-24.04-arm + build_type: RelWithDebInfo + target_triple: aarch64-linux-gnu + - os: windows-11-arm + build_type: RelWithDebInfo + target_triple: aarch64-pc-windows-msvc + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: ./.github/actions/setup-pixi + with: + environments: test-run + + - name: Download cross-compiled binaries + uses: actions/download-artifact@v4 + with: + name: cross-build-${{ matrix.target_triple }} + path: build/${{ matrix.build_type }}/ + + - name: Make binaries executable + if: runner.os != 'Windows' + run: chmod +x build/${{ matrix.build_type }}/bin/* + + - name: Unit tests + timeout-minutes: 5 + run: pixi run -e test-run unit-test ${{ matrix.build_type }} + + - name: Integration tests + timeout-minutes: 20 + run: pixi run -e test-run integration-test ${{ matrix.build_type }} + + - name: Smoke tests + timeout-minutes: 10 + run: pixi run -e test-run smoke-test ${{ matrix.build_type }} diff --git a/.gitea/workflows/upload-llvm.yml b/.gitea/workflows/upload-llvm.yml new file mode 100644 index 00000000..6ad5def1 --- /dev/null +++ b/.gitea/workflows/upload-llvm.yml @@ -0,0 +1,38 @@ +name: upload-llvm + +permissions: + contents: write + +on: + pull_request: + # if you want to run this workflow, change the branch name to main, + # if you want to turn off it, change it to non existent branch. + branches: [main-turn-off] + + workflow_dispatch: + inputs: + workflow_id: + description: "Workflow run ID to pull artifacts from" + required: true + type: string + version: + description: "Release version/tag to publish (e.g., v1.2.3)" + required: true + type: string + +jobs: + upload: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + + - name: Download artifacts from workflow + env: + GH_TOKEN: ${{ github.token }} + run: scripts/download-llvm.sh "${{ inputs.workflow_id }}" + + - name: Recreate release with artifacts + env: + GH_TOKEN: ${{ secrets.UPLOAD_LLVM }} + TARGET_REPO: clice-io/clice-llvm + run: python3 scripts/upload-llvm.py "${{ inputs.version }}" "${TARGET_REPO}" "${{ inputs.workflow_id }}"