From f21f2f2a955a36bad610f9afe35da7cc23747b2c Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Thu, 16 May 2024 09:50:08 +0200 Subject: [PATCH] ci: update workflows --- .github/workflows/ci.yml | 6 +- .github/workflows/lint.yml | 24 +++--- .github/workflows/linux.yml | 134 +++++++++------------------------- .github/workflows/macos.yml | 73 +++--------------- .github/workflows/release.yml | 57 +++++++++++++++ .github/workflows/windows.yml | 84 +++++---------------- 6 files changed, 134 insertions(+), 244 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8274df..e4c7dbd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,10 +14,12 @@ jobs: macOS: uses: ./.github/workflows/macos.yml - permissions: - contents: write windows: uses: ./.github/workflows/windows.yml + + release: + needs: [linux, macos, windows] + uses: ./.github/workflows/release.yml permissions: contents: write diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 98b4ef9..5da43fb 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,26 +3,22 @@ name: Lint on: workflow_call: -env: - REPO_NAME: ${{ github.event.repository.name }} - jobs: - fmt: + verify: 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 + - uses: actions/checkout@v4 + - name: Restore cache + uses: actions/cache/restore@v4 with: path: | - vlang + ~/v ~/.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 }} + run: ~/v/v symlink && v version + - name: Verify formatting + run: v fmt -verify . && exit 0 || v fmt -diff . && exit 1 + - name: Vet + run: v vet -W . diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index af292cb..c4b1b8d 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -3,33 +3,24 @@ 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 }} + - uses: actions/checkout@v4 - name: Checkout V uses: actions/checkout@v4 with: repository: 'vlang/v' - path: vlang + path: v - name: Setup V - run: cd ../vlang && make -j4 && ./v symlink && v version + run: mv v ~/v && cd ~/v && make -j4 && ./v symlink && v version - run: v install - name: Cache - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 with: path: | - vlang + ~/v ~/.vmodules key: ${{ runner.os }}-${{ github.sha }} @@ -37,6 +28,7 @@ jobs: needs: setup uses: ./.github/workflows/lint.yml + # TODO: update VFLAGS test: needs: setup strategy: @@ -51,24 +43,18 @@ jobs: 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 }} + - uses: actions/checkout@v4 - name: Restore Cache - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: | - vlang + ~/v ~/.vmodules key: ${{ runner.os }}-${{ github.sha }} fail-on-cache-miss: true - name: Setup V - run: ../vlang/v symlink && v version + run: ~/v/v symlink && v version - name: Build run: v . - name: Run @@ -79,105 +65,57 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - cc: [gcc, clang] - sanitizer: [address, leak] + include: + - cc: gcc + sanitizer: thread + - cc: gcc + sanitizer: address,leak,undefined,shift,shift-exponent,shift-base,integer-divide-by-zero,unreachable,vla-bound,null,return,signed-integer-overflow,bounds,bounds-strict,alignment,object-size,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr + - cc: clang + sanitizer: undefined + - cc: clang + sanitizer: memory fail-fast: false env: - VFLAGS: -cg -cc ${{ matrix.cc }} -o lvb - defaults: - run: - working-directory: ${{ env.REPO_NAME }} + VFLAGS: -cg -cc ${{ matrix.cc }} steps: - - name: Checkout ${{ env.REPO_NAME }} - uses: actions/checkout@v4 - with: - path: ${{ env.REPO_NAME }} - - name: Restore Cache - uses: actions/cache/restore@v3 + - uses: actions/checkout@v4 + - name: Restore cache + uses: actions/cache/restore@v4 with: path: | - vlang + ~/v ~/.vmodules key: ${{ runner.os }}-${{ github.sha }} fail-on-cache-miss: true - name: Setup V - run: ../vlang/v symlink && v version + run: ~/v/v symlink && v -showcc self && v doctor + - name: Setup zig + uses: goto-bus-stop/setup-zig@v2 - 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" + run: v -cflags -fsanitize=${{ matrix.sanitizer }} -o lvb . - 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 }} - deploy-example: - needs: [test] + needs: test runs-on: ubuntu-latest permissions: contents: write env: + VFLAGS: -cc ${{ matrix.cc }} -prod ARTIFACT: gui_project-linux-amd64 - defaults: - run: - working-directory: ${{ env.REPO_NAME }} steps: - - name: Checkout ${{ env.REPO_NAME }} - uses: actions/checkout@v4 - with: - path: ${{ env.REPO_NAME }} + - uses: actions/checkout@v4 - name: Restore Cache - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: | - vlang + ~/v ~/.vmodules key: ${{ runner.os }}-${{ github.sha }} fail-on-cache-miss: true - name: Setup V - run: ../vlang/v symlink && v version + run: ~/v/v symlink && v version - name: Install dependencies run: | sudo apt install -y -qq libgtk-3-dev libwebkit2gtk-4.0-dev @@ -190,7 +128,7 @@ jobs: ./build.vsh mv ./gui_project ./$ARTIFACT - name: Upload Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.ARTIFACT }} - path: ${{ env.REPO_NAME }}/examples/gui_project/${{ env.ARTIFACT }} + path: examples/gui_project/${{ env.ARTIFACT }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index efe3006..eaea0eb 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -3,33 +3,24 @@ 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 }} + - uses: actions/checkout@v4 - name: Checkout V uses: actions/checkout@v4 with: repository: 'vlang/v' - path: vlang + path: v - name: Setup V - run: cd ../vlang && make -j4 && ./v symlink && v version + run: mv v ~v && cd ~/v && make -j4 && ./v symlink && v version - run: v install - name: Cache - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 with: path: | - vlang + ~/v ~/.vmodules key: ${{ runner.os }}-${{ github.sha }} @@ -47,65 +38,19 @@ jobs: 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 }} + - uses: actions/checkout@v4 - name: Restore Cache - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: | - vlang + ~/v ~/.vmodules key: ${{ runner.os }}-${{ github.sha }} fail-on-cache-miss: true - name: Setup V - run: ../vlang/v symlink && v version + run: ~/v/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/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..5023e22 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ +name: Release + +on: + workflow_call: + +jobs: + deploy: + strategy: + matrix: + include: + - os: ubuntu-latest + cc: gcc + artifact: lvb-linux-amd64.exe + - os: windows-latest + cc: msvc + artifact: lvb-windows-amd64.exe + - os: macos-latest + cc: clang + cflags: -cflags "-target x86_64-apple-darwin" + artifact: lvb-macos-amd64.exe + - os: macos-latest + cc: clang + cflags: -cflags "-target arm64-apple-darwin" + artifact: lvb-macos-arm64.exe + fail-fast: false + runs-on: ${{ matrix.os }} + permissions: + contents: write + env: + VFLAGS: -cc ${{ matrix.cc }} -prod + steps: + - uses: actions/checkout@v4 + - name: Restore cache + uses: actions/cache/restore@v4 + with: + path: | + ~/v + ~/.vmodules + key: ${{ runner.os }}-${{ github.sha }} + fail-on-cache-miss: true + - name: Setup V + run: ~/v/v symlink && ~/v/v -showcc self + - name: Setup windows path + if: runner.os == 'Windows' + run: $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + - name: Build + run: v ${{ matrix.cflags }} -o ${{ matrix.artifact }} . + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact }} + path: ${{ matrix.artifact }} + - name: Release artifacts + if: github.ref_type == 'tag' + uses: softprops/action-gh-release@v2 + with: + files: ${{ matrix.artifact }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 288eb13..b9ad6b6 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -3,36 +3,26 @@ 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 }} + - uses: actions/checkout@v4 - name: Checkout V uses: actions/checkout@v4 with: repository: 'vlang/v' - path: vlang + path: v - 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 + bash mv v ~/v + cd ~/v && ./make.bat && ./v symlink + - run: v install - name: Cache - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 with: path: | - vlang + ~/v ~/.vmodules key: ${{ runner.os }}-${{ github.sha }} @@ -40,71 +30,33 @@ jobs: needs: setup strategy: matrix: - cc: [tcc, gcc] + cc: [tcc, gcc, msvc] # optimization: ['', -cstrict] # cstrict currently fails with pcre optimization: [''] - include: - - cc: gcc - optimization: -prod + exclude: + - cc: tcc + optimization: '-W -cstrict' 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 + - uses: actions/checkout@v4 - name: Restore Cache - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: | - vlang + ~/v ~/.vmodules key: ${{ runner.os }}-${{ github.sha }} fail-on-cache-miss: true - name: Setup V - run: vlang/v symlink - - name: Build run: | + ~/v/v symlink $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + v -showcc self && v doctor + - name: Build + run: | 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 }}