Skip to content

Commit

Permalink
Update ci.
Browse files Browse the repository at this point in the history
  • Loading branch information
fubark committed Jan 6, 2024
1 parent 9226b9f commit 3d0d00c
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 23 deletions.
76 changes: 63 additions & 13 deletions .github/workflows/gen-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,85 @@ on:
branches:
- master
paths:
- 'docs/hugo/**'
- 'docs/**'
- 'src/builtins/**'
jobs:
deploy:
runs-on: ubuntu-22.04
env:
ZIG_VERSION: 0.11.0
steps:
- uses: actions/checkout@v3
- name: Clone repo.
uses: actions/checkout@v3
with:
submodules: false
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod

- name: Install theme.
- name: Install zig.
run: |
git clone --depth=1 https://github.com/alex-shpak/hugo-book docs/hugo/themes/hugo-book
wget -c https://ziglang.org/builds/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
- name: Install Hugo.
uses: peaceiris/actions-hugo@v2
- name: Build md4c.
run: |
git clone --depth=1 https://github.com/mity/md4c.git
cd md4c
mkdir build
cd build
cmake ..
make
- name: Setup script.
uses: actions/github-script@v5
with:
hugo-version: 'latest'
# Needed to build SCSS/SASS with transpiler set to 'libsass'
extended: true
script: |
async function execCmd(name, args) {
const opts = {};
let out = '';
let err = '';
opts.listeners = {
stdout: (data) => {
out += data.toString();
},
stderr: (data) => {
process.stderr.write(data.toString());
}
};
// opt.cwd = './lib';
await exec.exec(name, args, opts);
return out;
}
const version = await execCmd('zig', ['build', 'version']);
const parts = version.split('.')
const last_version = parts[0] + '.' + (parseInt(parts[1])-1)
core.exportVariable('SHORT_VERSION', version);
await execCmd('git', ['fetch', '--all', '--tags']);
const build = await execCmd('git', ['rev-list', '--count', `${last_version}..${context.sha}`])
core.exportVariable('BUILD', build.trim());
core.exportVariable('COMMIT', context.sha.substring(0, 7));
- name: Cache.
uses: actions/cache@v2
with:
path: |-
~/.cache/zig
zig-cache
key:
build-1
restore-keys:
build-1

- name: Build Cyber.
run: zig build cli

- name: Generate.
- name: Generate docs.
run: |
cd docs/hugo
hugo --minify
LD_LIBRARY_PATH=`pwd`/md4c/build/src zig-out/bin/cyber docs/gen-docs.cy -version "${{ format('v{0}-dev {1}-{2}', env.SHORT_VERSION, env.BUILD, env.COMMIT) }}"
mkdir -p docs/public
mv docs/docs.html docs/public/index.html
- name: Deploy.
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/master'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/hugo/public
publish_dir: ./docs/public
102 changes: 98 additions & 4 deletions .github/workflows/latest-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ on:
paths-ignore:
- '.github/**'
- '**.md'
- 'docs/hugo/**'
- '.gitattributes'
- 'examples/**.cy'
- 'examples/**/*.cy'
Expand Down Expand Up @@ -168,9 +167,11 @@ jobs:
return out;
}
const version = await execCmd('zig', ['build', 'version']);
const parts = version.split('.')
const last_version = parts[0] + '.' + (parseInt(parts[1])-1)
core.exportVariable('SHORT_VERSION', version);
await execCmd('git', ['fetch', '--all', '--tags']);
const build = await execCmd('git', ['rev-list', '--count', `${version}..${context.sha}`])
const build = await execCmd('git', ['rev-list', '--count', `${last_version}..${context.sha}`])
core.exportVariable('BUILD', build.trim());
core.exportVariable('COMMIT', context.sha.substring(0, 7));
Expand Down Expand Up @@ -295,8 +296,97 @@ jobs:
short_version: ${{ env.SHORT_VERSION }}
# version: ${{ env.BUILD_VERSION }}

docs:
runs-on: ubuntu-22.04
env:
ZIG_VERSION: 0.11.0
steps:
- name: Clone repo.
uses: actions/checkout@v3
with:
submodules: false
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod

- name: Install zig.
run: |
wget -c https://ziglang.org/builds/zig-linux-x86_64-${{ env.ZIG_VERSION }}.tar.xz -O - | tar -xJ --strip-components=1 -C /usr/local/bin
- name: Build md4c.
run: |
git clone --depth=1 https://github.com/mity/md4c.git
cd md4c
mkdir build
cd build
cmake ..
make
- name: Setup script.
uses: actions/github-script@v5
with:
script: |
async function execCmd(name, args) {
const opts = {};
let out = '';
let err = '';
opts.listeners = {
stdout: (data) => {
out += data.toString();
},
stderr: (data) => {
process.stderr.write(data.toString());
}
};
// opt.cwd = './lib';
await exec.exec(name, args, opts);
return out;
}
const version = await execCmd('zig', ['build', 'version']);
const parts = version.split('.')
const last_version = parts[0] + '.' + (parseInt(parts[1])-1)
core.exportVariable('SHORT_VERSION', version);
await execCmd('git', ['fetch', '--all', '--tags']);
const build = await execCmd('git', ['rev-list', '--count', `${last_version}..${context.sha}`])
core.exportVariable('BUILD', build.trim());
core.exportVariable('COMMIT', context.sha.substring(0, 7));
- name: Cache.
uses: actions/cache@v2
with:
path: |-
~/.cache/zig
zig-cache
key:
build-1
restore-keys:
build-1

- name: Build Cyber.
run: zig build cli

- name: Generate docs. (Release)
if: startsWith(github.ref, 'refs/tags/')
run: |
LD_LIBRARY_PATH=`pwd`/md4c/build/src zig-out/bin/cyber docs/gen-docs.cy -version v${{ env.SHORT_VERSION }}
mv docs/docs-modules.md docs.md
mv docs/docs.html docs.html
- name: Generate docs. (Dev)
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
run: |
LD_LIBRARY_PATH=`pwd`/md4c/build/src zig-out/bin/cyber docs/gen-docs.cy -version "${{ format('v{0}-dev {1}-{2}', env.SHORT_VERSION, env.BUILD, env.COMMIT) }}"
mv docs/docs-modules.md docs.md
mv docs/docs.html docs.html
- name: Save artifact.
uses: actions/upload-artifact@v2
with:
name: bin
path: |
docs.html
docs.md
release:
needs: build
needs: [build, docs]
name: Release
runs-on: ubuntu-22.04
steps:
Expand All @@ -312,7 +402,7 @@ jobs:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: latest
prerelease: false
title: v${{ needs.build.outputs.short_version }}-Latest
title: v${{ needs.build.outputs.short_version }}-dev
files: |
cyber-linux-x64.tar.gz
cyber-selinux-x64.tar.gz
Expand All @@ -325,6 +415,8 @@ jobs:
libcyber-macos-arm64.a
cyber-web.wasm
cyber-wasi.wasm
docs.html
docs.md
# Auto dispatch.
- name: Github Release.
Expand All @@ -344,3 +436,5 @@ jobs:
libcyber-macos-arm64.a
cyber-web.wasm
cyber-wasi.wasm
docs.html
docs.md
1 change: 0 additions & 1 deletion .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:
pull_request:
paths-ignore:
- '.github/**'
- 'docs/hugo/**'
- '**.md'
concurrency:
group: pr-${{ github.ref }}
Expand Down
4 changes: 2 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const config = @import("src/config.zig");
const mimalloc_lib = @import("lib/mimalloc/lib.zig");
const tcc_lib = @import("lib/tcc/lib.zig");

// FIND: v0.3
const Version = "0.3";
// FIND: v0.4
const Version = "0.4";

var optMalloc: ?config.Allocator = undefined;
var selinux: bool = undefined;
Expand Down
2 changes: 1 addition & 1 deletion docs/gen-docs.cy
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import os
import md '../src/tools/md4c.cy'

var args = os.parseArgs([
[ name: 'version', type: string, default: 'v0.4-dev' ],
[ name: 'version', type: string, default: 'dev' ],
])

genDocsModules()
Expand Down
8 changes: 7 additions & 1 deletion src/tools/md4c.cy
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
-- ./src/tools/cbindgen.cy -o src/tools/md4c.cy ~/repos/md4c/src/md4c.h -I/opt/homebrew/Cellar/llvm/17.0.5/include -libpath libmd4c.dylib -stripPrefix MD

var Root.libPath = switch os.system:
case 'linux' => 'libmd4c.so'
case 'windows' => 'md4c.dll'
case 'macos' => 'libmd4c.dylib'
else => throw error.Unsupported

-- CBINDGEN MARKER
-- Code below is generated by cbindgen.cy
type CHAR int
Expand Down Expand Up @@ -158,7 +164,7 @@ func load():
ffi.cbind(SPAN_WIKILINK_S, [ATTRIBUTE])
ffi.cbind(PARSER_S, [.uint, .uint, .voidPtr, .voidPtr, .voidPtr, .voidPtr, .voidPtr, .voidPtr, .voidPtr])
ffi.cfunc('md_parse', [.voidPtr, .uint, .voidPtr, .voidPtr], .int)
my lib = ffi.bindLib('libmd4c.dylib', [genMap: true])
my lib = ffi.bindLib(libPath, [genMap: true])
md_parse = lib.md_parse
return lib

Expand Down
5 changes: 4 additions & 1 deletion test/behavior_test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3350,12 +3350,15 @@ test "examples" {

test "tools" {
try compile(.{}, @embedFile("../src/tools/bench.cy"));
try compile(.{}, @embedFile("../src/tools/llvm.cy"));
try compile(.{}, @embedFile("../src/tools/clang_bs.cy"));
try compile(.{}, @embedFile("../src/tools/md4c.cy"));
if (!cy.isWasm) {
try compile(Config.initFileModules("./src/tools/cbindgen.cy"), @embedFile("../src/tools/cbindgen.cy"));
try compile(Config.initFileModules("./docs/gen-docs.cy"), @embedFile("../docs/gen-docs.cy"));
try compile(Config.initFileModules("./src/jit/gen-stencils-a64.cy"), @embedFile("../src/jit/gen-stencils-a64.cy"));
try compile(Config.initFileModules("./src/jit/gen-stencils-x64.cy"), @embedFile("../src/jit/gen-stencils-x64.cy"));
}
try compile(.{}, @embedFile("../docs/gen-modules.cy"));
}

test "benchmarks" {
Expand Down

0 comments on commit 3d0d00c

Please sign in to comment.