From 76f4c5e94c3aee2d56e0a73fdc3f282b483c720b Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Thu, 2 Nov 2023 08:08:41 +0100 Subject: [PATCH] ci: add workflows --- .github/workflows/ci.yml | 23 +++++ .github/workflows/lint.yml | 28 +++++++ .github/workflows/linux.yml | 154 ++++++++++++++++++++++++++++++++++ .github/workflows/macos.yml | 111 ++++++++++++++++++++++++ .github/workflows/windows.yml | 110 ++++++++++++++++++++++++ 5 files changed, 426 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/linux.yml create mode 100644 .github/workflows/macos.yml create mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b8274df --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,23 @@ +name: CI + +on: + push: + paths-ignore: ['**/*.md'] + pull_request: + paths-ignore: ['**/*.md'] + +jobs: + linux: + uses: ./.github/workflows/linux.yml + permissions: + contents: write + + macOS: + uses: ./.github/workflows/macos.yml + permissions: + contents: write + + windows: + uses: ./.github/workflows/windows.yml + permissions: + contents: write diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..98b4ef9 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,28 @@ +name: Lint + +on: + workflow_call: + +env: + REPO_NAME: ${{ github.event.repository.name }} + +jobs: + fmt: + runs-on: ubuntu-latest + steps: + - name: Checkout ${{ env.REPO_NAME }} + uses: actions/checkout@v4 + with: + path: ${{ env.REPO_NAME }} + - name: Restore Cache + uses: actions/cache/restore@v3 + with: + path: | + vlang + ~/.vmodules + key: ${{ runner.os }}- + fail-on-cache-miss: true + - name: Setup V + run: vlang/v symlink && v version + - name: Check Formatting + run: v fmt ${{ env.REPO_NAME }} && v fmt -verify ${{ env.REPO_NAME }} diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..b700ea0 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,154 @@ +name: Linux + +on: + workflow_call: + +env: + REPO_NAME: ${{ github.event.repository.name }} + +jobs: + setup: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ${{ env.REPO_NAME }} + steps: + - name: Checkout ${{ env.REPO_NAME }} + uses: actions/checkout@v4 + with: + path: ${{ env.REPO_NAME }} + - name: Checkout V + uses: actions/checkout@v4 + with: + repository: 'vlang/v' + path: vlang + - name: Setup V + run: cd ../vlang && make -j4 && ./v symlink && v version + - run: v install + - name: Cache + uses: actions/cache/save@v3 + with: + path: | + vlang + ~/.vmodules + key: ${{ runner.os }}-${{ github.sha }} + + lint: + needs: setup + uses: ./.github/workflows/lint.yml + + test: + needs: setup + strategy: + matrix: + cc: [tcc, gcc, clang] + # optimization: ['', -prod, -cstrict] # cstrict currently fails with pcre + optimization: ['', -prod] + exclude: + - cc: tcc + optimization: -prod + fail-fast: false + runs-on: ubuntu-latest + env: + VFLAGS: -cg -cc ${{ matrix.cc }} ${{ matrix.optimization }} -o lvb + defaults: + run: + working-directory: ${{ env.REPO_NAME }} + steps: + - name: Checkout ${{ env.REPO_NAME }} + uses: actions/checkout@v4 + with: + path: ${{ env.REPO_NAME }} + - name: Restore Cache + uses: actions/cache/restore@v3 + with: + path: | + vlang + ~/.vmodules + key: ${{ runner.os }}-${{ github.sha }} + fail-on-cache-miss: true + - name: Setup V + run: ../vlang/v symlink && v version + - name: Build + run: v . + - name: Run + run: ./lvb . + + test-sanitzed: + needs: setup + runs-on: ubuntu-latest + strategy: + matrix: + cc: [gcc, clang] + sanitizer: [address, leak] + fail-fast: false + env: + VFLAGS: -cg -cc ${{ matrix.cc }} -o lvb + defaults: + run: + working-directory: ${{ env.REPO_NAME }} + steps: + - name: Checkout ${{ env.REPO_NAME }} + uses: actions/checkout@v4 + with: + path: ${{ env.REPO_NAME }} + - name: Restore Cache + uses: actions/cache/restore@v3 + with: + path: | + vlang + ~/.vmodules + key: ${{ runner.os }}-${{ github.sha }} + fail-on-cache-miss: true + - name: Setup V + run: ../vlang/v symlink && v version + - name: Build + run: | + if [[ ${{ matrix.cc }} == "gcc" && ${{ matrix.sanitizer }} == "address" ]]; then + cmd="v $VFLAGS -cflags -fsanitize=address -cflags -fsanitize-address-use-after-scope -cflags -fsanitize=pointer-compare -cflags -fsanitize=pointer-subtract ." + else + cmd="v $VFLAGS -cflags -fsanitize=${{ matrix.sanitizer }} ." + fi + echo "$cmd" + eval "$cmd" + - name: Run + run: ./lvb . + + deploy: + needs: [test, test-sanitzed, lint] + runs-on: ubuntu-latest + permissions: + contents: write + env: + ARTIFACT: lvb-linux-amd64 + VFLAGS: -cc gcc -prod + defaults: + run: + working-directory: ${{ env.REPO_NAME }} + steps: + - name: Checkout ${{ env.REPO_NAME }} + uses: actions/checkout@v4 + with: + path: ${{ env.REPO_NAME }} + - name: Restore Cache + uses: actions/cache/restore@v3 + with: + path: | + vlang + ~/.vmodules + key: ${{ runner.os }}-${{ github.sha }} + fail-on-cache-miss: true + - name: Setup V + run: ../vlang/v symlink && v version + - name: Build + run: v -cc gcc -prod -o $ARTIFACT . + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ env.ARTIFACT }} + path: ${{ env.REPO_NAME }}/${{ env.ARTIFACT }} + - name: Release Artifacts + if: github.ref_type == 'tag' + uses: softprops/action-gh-release@v1 + with: + files: ${{ env.REPO_NAME }}/${{ env.ARTIFACT }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..efe3006 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,111 @@ +name: macOS + +on: + workflow_call: + +env: + REPO_NAME: ${{ github.event.repository.name }} + +jobs: + setup: + runs-on: macos-latest + defaults: + run: + working-directory: ${{ env.REPO_NAME }} + steps: + - name: Checkout ${{ env.REPO_NAME }} + uses: actions/checkout@v4 + with: + path: ${{ env.REPO_NAME }} + - name: Checkout V + uses: actions/checkout@v4 + with: + repository: 'vlang/v' + path: vlang + - name: Setup V + run: cd ../vlang && make -j4 && ./v symlink && v version + - run: v install + - name: Cache + uses: actions/cache/save@v3 + with: + path: | + vlang + ~/.vmodules + key: ${{ runner.os }}-${{ github.sha }} + + test: + needs: setup + strategy: + matrix: + cc: [tcc, clang] + # optimization: ['', -cstrict] # cstrict currently fails with pcre + optimization: [''] + include: + - cc: clang + optimization: -prod + fail-fast: false + runs-on: macos-latest + env: + VFLAGS: -cg -cc ${{ matrix.cc }} ${{ matrix.optimization }} -o lvb + defaults: + run: + working-directory: ${{ env.REPO_NAME }} + steps: + - name: Checkout ${{ env.REPO_NAME }} + uses: actions/checkout@v4 + with: + path: ${{ env.REPO_NAME }} + - name: Restore Cache + uses: actions/cache/restore@v3 + with: + path: | + vlang + ~/.vmodules + key: ${{ runner.os }}-${{ github.sha }} + fail-on-cache-miss: true + - name: Setup V + run: ../vlang/v symlink && v version + - name: Build + run: v . + - name: Run + run: ./lvb . + + deploy: + needs: test + runs-on: macos-latest + permissions: + contents: write + env: + ARTIFACT: lvb-macos-amd64 + defaults: + run: + working-directory: ${{ env.REPO_NAME }} + steps: + - name: Checkout ${{ env.REPO_NAME }} + uses: actions/checkout@v4 + with: + path: ${{ env.REPO_NAME }} + - name: Restore Cache + uses: actions/cache/restore@v3 + with: + path: | + vlang + ~/.vmodules + key: ${{ runner.os }}-${{ github.sha }} + fail-on-cache-miss: true + - name: Setup V + run: ../vlang/v symlink && v version + - name: Build + run: v -cc clang -prod -o $ARTIFACT . + - name: Verify + run: v fmt . && v fmt -verify . + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ env.ARTIFACT }} + path: ${{ env.REPO_NAME }}/${{ env.ARTIFACT }} + - name: Release Artifacts + if: github.ref_type == 'tag' + uses: softprops/action-gh-release@v1 + with: + files: ${{ env.REPO_NAME }}/${{ env.ARTIFACT }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..288eb13 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,110 @@ +name: Windows + +on: + workflow_call: + +env: + REPO_NAME: ${{ github.event.repository.name }} + +jobs: + setup: + runs-on: windows-latest + defaults: + run: + working-directory: ${{ env.REPO_NAME }} + steps: + - name: Checkout ${{ env.REPO_NAME }} + uses: actions/checkout@v4 + with: + path: ${{ env.REPO_NAME }} + - name: Checkout V + uses: actions/checkout@v4 + with: + repository: 'vlang/v' + path: vlang + - name: Setup V + run: cd ../vlang && ./make.bat && ./v symlink + - name: v install + run: | + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + v install + - name: Cache + uses: actions/cache/save@v3 + with: + path: | + vlang + ~/.vmodules + key: ${{ runner.os }}-${{ github.sha }} + + test: + needs: setup + strategy: + matrix: + cc: [tcc, gcc] + # optimization: ['', -cstrict] # cstrict currently fails with pcre + optimization: [''] + include: + - cc: gcc + optimization: -prod + fail-fast: false + runs-on: windows-latest + env: + VFLAGS: -cg -cc ${{ matrix.cc }} ${{ matrix.optimization }} -o lvb.exe + steps: + - name: Checkout ${{ env.REPO_NAME }} + uses: actions/checkout@v4 + - name: Restore Cache + uses: actions/cache/restore@v3 + with: + path: | + vlang + ~/.vmodules + key: ${{ runner.os }}-${{ github.sha }} + fail-on-cache-miss: true + - name: Setup V + run: vlang/v symlink + - name: Build + run: | + $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + v . + - name: Run + run: ./lvb . + + deploy: + needs: test + runs-on: windows-latest + permissions: + contents: write + env: + ARTIFACT: lvb-windows-amd64.exe + defaults: + run: + shell: bash + working-directory: ${{ env.REPO_NAME }} + steps: + - name: Checkout ${{ env.REPO_NAME }} + uses: actions/checkout@v4 + with: + path: ${{ env.REPO_NAME }} + - name: Checkout V + uses: actions/checkout@v4 + with: + repository: 'vlang/v' + path: vlang + - name: Setup V + run: cd ../vlang && ./make.bat + - run: ../vlang/v install + - name: Build + run: ../vlang/v -cc gcc -prod -o $ARTIFACT . + - name: Verify + run: ../vlang/v fmt . && ../vlang/v fmt -verify . + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ env.ARTIFACT }} + path: ${{ env.REPO_NAME }}/${{ env.ARTIFACT }} + - name: Release Artifacts + if: github.ref_type == 'tag' + uses: softprops/action-gh-release@v1 + with: + files: ${{ env.REPO_NAME }}/${{ env.ARTIFACT }}