Skip to content

Commit

Permalink
ci: add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Nov 5, 2023
1 parent 1c90213 commit 76f4c5e
Show file tree
Hide file tree
Showing 5 changed files with 426 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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 }}
154 changes: 154 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -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 }}
111 changes: 111 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -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 }}
Loading

0 comments on commit 76f4c5e

Please sign in to comment.