diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fef8a75..4211aa4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,8 +9,6 @@ on: jobs: linux: uses: ./.github/workflows/linux.yml - permissions: - contents: write macos: uses: ./.github/workflows/macos.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 2eae875..4e0ce21 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,51 +1,38 @@ -# Simple workflow for deploying static content to GitHub Pages -name: Deploy docs to GitHub Pages +name: Docs on: - # Runs on pushes targeting the default branch and docs path push: - branches: ['main'] - # Allows you to run this workflow manually from the Actions tab + branches: [main] + paths-ignore: ['**.yml', '!.github/workflows/docs.yml'] workflow_dispatch: -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: - group: 'pages' - cancel-in-progress: false + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref_name != 'main' }} jobs: - # Single deploy job since we're just deploying deploy: + if: github.repository == 'ttytm/webview' + runs-on: ubuntu-latest + permissions: + contents: read + pages: write + id-token: write environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest steps: - - name: Setup Pages - uses: actions/configure-pages@v3 - - name: Install V - uses: vlang/setup-v@v1.3 - with: - check-latest: true - - name: Checkout - uses: actions/checkout@v3 - with: - path: webview + - uses: actions/checkout@v4 + - name: Setup pages + uses: actions/configure-pages@v5 + - name: Setup V + uses: vlang/setup-v@v1.4 - name: Build docs - run: | - cd webview - ./build.vsh docs + run: ./build.vsh docs - name: Upload artifact - uses: actions/upload-pages-artifact@v2 + uses: actions/upload-pages-artifact@v3 with: - path: 'webview/_docs' - - name: Deploy to GitHub Pages + path: '_docs' + - name: Deploy to GitHub pages id: deployment - uses: actions/deploy-pages@v2 + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/lint-docs.yml b/.github/workflows/lint-docs.yml deleted file mode 100644 index e74ee0c..0000000 --- a/.github/workflows/lint-docs.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Lint Docs - -on: - push: - paths: ['**/*.md', '**/*.yml'] - pull_request: - -env: - REPO_NAME: ${{ github.event.repository.name }} - -jobs: - check-docs: - runs-on: ubuntu-latest - steps: - - name: Setup V - uses: vlang/setup-v@v1.3 - - name: Setup Dependencies - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: libgtk-3-dev libwebkit2gtk-4.0-dev - version: 1.0 - - name: Checkout ${{ env.REPO_NAME }} - uses: actions/checkout@v3 - with: - path: ${{ env.REPO_NAME }} - - name: Check Markdown - run: v check-md -hide-warnings ${{ env.REPO_NAME }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1e0c6af..766b5d9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -3,38 +3,50 @@ name: Lint on: workflow_call: -env: - MOD_PATH: ~/.vmodules/ttytm/webview - jobs: fmt: runs-on: ubuntu-latest steps: - - name: Restore Cache - uses: actions/cache/restore@v3 + - 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 - uses: vlang/setup-v@v1.3 - - name: Check Formatting - run: v fmt -verify ${{ env.MOD_PATH }} + - name: Verify formatting + run: ~/v/v fmt -verify ~/.vmodules/ttytm/webview && exit 0 || ~/v/v fmt -diff . && exit 1 vet: runs-on: ubuntu-latest steps: - - name: Restore Cache - uses: actions/cache/restore@v3 + - name: Restore cache + uses: actions/cache/restore@v4 + with: + path: | + ~/v + ~/.vmodules + key: ${{ runner.os }}-${{ github.sha }} + fail-on-cache-miss: true + - name: Vet + run: ~/v/v vet -W ~/.vmodules/ttytm/webview + + check-md: + runs-on: ubuntu-latest + steps: + - 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 - uses: vlang/setup-v@v1.3 - - name: Run Vet - run: v vet -W ${{ env.MOD_PATH }}/src/ + - name: Setup dependencies + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: libcurl4-openssl-dev + version: 1.0 + - name: Check markdown + run: ~/v/v check-md -hide-warnings ~/.vmodules/ttytm/webview diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 21036d6..66d1769 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -3,40 +3,33 @@ name: CI Linux on: workflow_call: -env: - REPO_NAME: ${{ github.event.repository.name }} - # Path where the module is installed with `v install ` - MOD_PATH: ~/.vmodules/ttytm/webview - jobs: setup: runs-on: ubuntu-latest steps: - - name: Install V - uses: vlang/setup-v@v1.3 + - uses: actions/checkout@v4 with: - check-latest: true - - name: Setup Dependencies + path: webview + - name: Setup V + run: | + curl -Lo v_linux.zip https://github.com/vlang/v/releases/latest/download/v_linux.zip + unzip -o v_linux.zip + mv v ~/v + ~/v/v symlink + - name: Setup dependencies uses: awalsh128/cache-apt-pkgs-action@latest with: packages: libgtk-3-dev libwebkit2gtk-4.0-dev version: 1.0 - - name: Setup ~/.vmodules - run: mkdir -p ~/.vmodules/ttytm - - name: Checkout ${{ env.REPO_NAME }} - uses: actions/checkout@v3 - with: - path: ${{ env.REPO_NAME }} - - name: Setup ${{ env.REPO_NAME }} + - name: Setup V module run: | - ${{ env.REPO_NAME }}/build.vsh --silent - mkdir -p ~/.vmodules/ttytm/ # `${{ env.MOD_PATH }}` runs into a dir not found error during tests. - cp -r ${{ env.REPO_NAME }} ${{ env.MOD_PATH }} - - name: Cache - uses: actions/cache/save@v3 + mkdir -p ~/.vmodules/ttytm && mv webview ~/.vmodules/ttytm/webview + ~/.vmodules/ttytm/webview/build.vsh --silent + - name: Save cache + uses: actions/cache/save@v4 with: path: | - vlang + ~/v ~/.vmodules key: ${{ runner.os }}-${{ github.sha }} @@ -44,94 +37,83 @@ jobs: needs: setup uses: ./.github/workflows/lint.yml - build: + test: needs: setup runs-on: ubuntu-latest strategy: matrix: - compiler: [tcc, gcc, clang] - optimization: ['', '-cstrict'] + cc: [tcc, gcc, clang] + optimization: ['', '-W -cstrict'] exclude: - - compiler: clang - optimization: -cstrict + - cc: tcc + optimization: '-W -cstrict' + - cc: clang + optimization: '-W -cstrict' fail-fast: false + env: + VFLAGS: -cg -cc ${{ matrix.cc }} ${{ matrix.optimization }} steps: - - name: Restore Cache - uses: actions/cache/restore@v3 + - 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 - uses: vlang/setup-v@v1.3 - - name: Setup Dependencies + run: ~/v/v symlink && v -showcc self && v doctor + - name: Setup dependencies uses: awalsh128/cache-apt-pkgs-action@latest with: packages: libgtk-3-dev libwebkit2gtk-4.0-dev version: 1.0 - - name: Build + - name: Test + run: xvfb-run v -stats test ~/.vmodules/ttytm/webview/tests/ + - name: Build examples run: | - for example_dir in $(find ${{ env.MOD_PATH }}/examples/* -maxdepth 0 -type d); do - cmd="v -cg -cc ${{ matrix.compiler }} ${{ matrix.optimization }} $example_dir/" + for example_dir in $(find ~/.vmodules/ttytm/webview/examples/* -maxdepth 0 -type d); do + cmd="v $example_dir/" [[ "$example_dir" =~ .*"emoji-picker"$ ]] && cmd+="main.v" echo "$cmd" eval "$cmd" done - test: - needs: setup - runs-on: ubuntu-latest - steps: - - 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 - uses: vlang/setup-v@v1.3 - - name: Setup Dependencies - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: libgtk-3-dev libwebkit2gtk-4.0-dev - version: 1.0 - - name: Test - run: xvfb-run v -stats test ${{ env.MOD_PATH }}/tests/ - test-sanitized: - needs: test + if: false # Skip sanitzed tests until issues are addressed. + needs: setup runs-on: ubuntu-latest strategy: matrix: - compiler: [gcc] include: - - compiler: gcc - sanitizer: -cflags -fsanitize=undefined -cflags -fsanitize=shift -cflags -fsanitize=shift-exponent -cflags -fsanitize=shift-base -cflags -fsanitize=integer-divide-by-zero -cflags -fsanitize=unreachable -cflags -fsanitize=vla-bound -cflags -fsanitize=null -cflags -fsanitize=return -cflags -fsanitize=signed-integer-overflow -cflags -fsanitize=bounds -cflags -fsanitize=bounds-strict -cflags -fsanitize=alignment -cflags -fsanitize=object-size -cflags -fsanitize=float-divide-by-zero -cflags -fsanitize=float-cast-overflow -cflags -fsanitize=nonnull-attribute -cflags -fsanitize=returns-nonnull-attribute -cflags -fsanitize=bool -cflags -fsanitize=enum -cflags -fsanitize=vptr -cflags -fsanitize=pointer-overflow -cflags -fsanitize=builtin - # sanitizer: -cflags -fsanitize=leak - # sanitizer: -cflags -fsanitize=address -cflags -fsanitize-address-use-after-scope -cflags -fsanitize=pointer-compare -cflags -fsanitize=pointer-subtract - # - compiler: clang - # sanitizer: address - # sanitizer: memory - # sanitizer: leak + - 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: gcc + sanitizer: thread + - cc: clang + sanitizer: address,leak,undefined + - cc: clang + sanitizer: thread + - cc: clang + sanitizer: memory + fail-fast: false + env: + VFLAGS: -cg -cc ${{ matrix.cc }} steps: - - name: Restore Cache - uses: actions/cache/restore@v3 + - 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 - uses: vlang/setup-v@v1.3 - - name: Setup Dependencies + run: ~/v/v symlink && v -showcc self && v doctor + - name: Setup dependencies uses: awalsh128/cache-apt-pkgs-action@latest with: packages: libgtk-3-dev libwebkit2gtk-4.0-dev version: 1.0 - name: Test - run: xvfb-run v -cc gcc ${{ matrix.sanitizer }} test ${{ env.MOD_PATH }}/tests/ + run: xvfb-run v -stats -cflags -fsanitize=${{ matrix.sanitizer }} test ~/.vmodules/ttytm/webview/tests/ diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index f2c251e..615fa07 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -12,48 +12,53 @@ jobs: setup: runs-on: macos-latest steps: - - name: Install V - uses: vlang/setup-v@v1.3 + - uses: actions/checkout@v4 with: - check-latest: true - - name: Checkout ${{ env.REPO_NAME }} - uses: actions/checkout@v3 - with: - path: ${{ env.REPO_NAME }} - - name: Setup ${{ env.REPO_NAME }} + path: webview + - name: Setup V + run: | + curl -Lo v_macos_arm64.zip https://github.com/vlang/v/releases/latest/download/v_macos_arm64.zip + unzip -o v_macos_arm64.zip + mv v ~/v + ~/v/v symlink + - name: Setup V module run: | - ${{ env.REPO_NAME }}/build.vsh --silent - mkdir -p ${{ env.MOD_PATH }} - cp -r ${{ env.REPO_NAME }} ${{ env.MOD_PATH }} - - name: Cache - uses: actions/cache/save@v3 + mkdir -p ~/.vmodules/ttytm && mv webview ~/.vmodules/ttytm/webview + ~/.vmodules/ttytm/webview/build.vsh --silent + - name: Save cache + uses: actions/cache/save@v4 with: path: | - vlang + ~/v ~/.vmodules key: ${{ runner.os }}-${{ github.sha }} - build: + test: needs: setup runs-on: macos-latest strategy: matrix: - compiler: [gcc, clang] + cc: [tcc, clang] + optimization: ['', '-W -cstrict'] + exclude: + - cc: tcc + optimization: '-W -cstrict' + fail-fast: false steps: - - name: Restore Cache - uses: actions/cache/restore@v3 + - 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 - uses: vlang/setup-v@v1.3 - - name: Build + run: ~/v/v symlink && v -showcc self && v doctor + - name: Build examples run: | - for example_dir in $(find ${{ env.MOD_PATH }}/examples/* -maxdepth 0 -type d); do - cmd="v -cg -cc ${{ matrix.compiler }} ${{ matrix.optimization }} $example_dir/" + for example_dir in $(find ~/.vmodules/ttytm/webview/examples/* -maxdepth 0 -type d); do + cmd="v $example_dir/" [[ "$example_dir" =~ .*"emoji-picker"$ ]] && cmd+="main.v" echo "$cmd" eval "$cmd" diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 2cf32df..bb36841 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -7,57 +7,62 @@ defaults: run: shell: bash -env: - REPO_NAME: ${{ github.event.repository.name }} - # Path where the module is installed with `v install ` - MOD_PATH: ~/.vmodules/ttytm/webview - jobs: setup: runs-on: windows-latest steps: - - name: Install V - uses: vlang/setup-v@v1.3 - with: - check-latest: true - - name: Checkout ${{ env.REPO_NAME }} - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: - path: ${{ env.REPO_NAME }} - - name: Setup ${{ env.REPO_NAME }} + path: webview + - name: Setup V + shell: bash run: | - ${{ env.REPO_NAME }}/build.vsh --silent - mkdir -p ${{ env.MOD_PATH }} - cp -r ${{ env.REPO_NAME }} ${{ env.MOD_PATH }} - - name: Cache - uses: actions/cache/save@v3 + curl -Lo v_windows.zip https://github.com/vlang/v/releases/latest/download/v_windows.zip + 7z x v_windows.zip + mv v ~/v + ~/v/v symlink + - name: Setup V module + run: | + bash -c "mkdir -p ~/.vmodules/ttytm && mv webview ~/.vmodules/ttytm/webview" + ~/.vmodules/ttytm/webview/build.vsh --silent + - name: Save cache + uses: actions/cache/save@v4 with: path: | - vlang + ~/v ~/.vmodules key: ${{ runner.os }}-${{ github.sha }} - build: + test: needs: setup runs-on: windows-latest strategy: matrix: - compiler: [gcc] + cc: [gcc] # [tcc, gcc, msvc] + optimization: ['', '-W -cstrict'] + # exclude: + # - cc: tcc + # optimization: '-W -cstrict' + fail-fast: false + env: + VFLAGS: -cg -cc ${{ matrix.cc }} steps: - - name: Restore Cache - uses: actions/cache/restore@v3 + - 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 - uses: vlang/setup-v@v1.3 - - name: Build + - name: Symlink V + run: ~/v/v symlink + - name: Compile V with ${{ matrix.cc }} + run: v -showcc self && v doctor + - name: Build examples run: | - for example_dir in $(find ${{ env.MOD_PATH }}/examples/* -maxdepth 0 -type d); do - cmd="v -cg -cc ${{ matrix.compiler }} ${{ matrix.optimization }} $example_dir/" + for example_dir in $(find ~/.vmodules/ttytm/webview/examples/* -maxdepth 0 -type d); do + cmd="v $example_dir/" [[ "$example_dir" =~ .*"emoji-picker"$ ]] && cmd+="main.v" echo "$cmd" eval "$cmd"