upgrade to zig 0.15.2 / refactored lambda-zig
All checks were successful
Lambda-Zig-Sample Build / build (push) Successful in 2m30s
All checks were successful
Lambda-Zig-Sample Build / build (push) Successful in 2m30s
This commit is contained in:
parent
9a4505e3b7
commit
c93062aa5d
7 changed files with 111 additions and 50 deletions
40
.forgejo/workflows/build.yaml
Normal file
40
.forgejo/workflows/build.yaml
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
name: Lambda-Zig-Sample Build
|
||||
run-name: ${{ github.actor }} building lambda-zig-sample
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Zig
|
||||
uses: https://codeberg.org/mlugg/setup-zig@v2.2.1
|
||||
|
||||
- name: Build
|
||||
run: zig build --summary all
|
||||
|
||||
- name: Package for lambda
|
||||
run: zig build awslambda_package -Dtarget=aarch64-linux --summary all
|
||||
|
||||
- name: Run tests
|
||||
run: zig build test --summary all
|
||||
|
||||
- name: Build for other platforms
|
||||
run: |
|
||||
zig build -Dtarget=aarch64-linux
|
||||
zig build -Dtarget=x86_64-linux
|
||||
|
||||
- name: Notify
|
||||
uses: https://git.lerch.org/lobo/action-notify-ntfy@v2
|
||||
if: always()
|
||||
with:
|
||||
host: ${{ secrets.NTFY_HOST }}
|
||||
topic: ${{ secrets.NTFY_TOPIC }}
|
||||
user: ${{ secrets.NTFY_USER }}
|
||||
password: ${{ secrets.NTFY_PASSWORD }}
|
||||
29
.github/workflows/zig-build.yaml
vendored
29
.github/workflows/zig-build.yaml
vendored
|
|
@ -1,29 +0,0 @@
|
|||
name: Generic zig build
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
- '!zig-develop*'
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: elerch/setup-zig@v3
|
||||
with:
|
||||
version: 0.13.0
|
||||
- uses: elerch/zig-action-cache@v1.1.6
|
||||
- name: Build project
|
||||
run: zig build --summary all
|
||||
- name: Run tests
|
||||
run: zig build test --summary all
|
||||
- name: Notify
|
||||
uses: elerch/action-notify-ntfy@v2.github
|
||||
if: always() && env.GITEA_ACTIONS == 'true'
|
||||
with:
|
||||
host: ${{ secrets.NTFY_HOST }}
|
||||
topic: ${{ secrets.NTFY_TOPIC }}
|
||||
status: ${{ job.status }}
|
||||
user: ${{ secrets.NTFY_USER }}
|
||||
password: ${{ secrets.NTFY_PASSWORD }}
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,2 +1,2 @@
|
|||
zig-out
|
||||
zig-cache
|
||||
zig-out/
|
||||
.zig-cache/
|
||||
|
|
|
|||
5
.mise.toml
Normal file
5
.mise.toml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
[tools]
|
||||
pre-commit = "4.2.0"
|
||||
zig = "0.15.2"
|
||||
zls = "0.15.1"
|
||||
"ubi:DonIsaac/zlint" = "0.7.6"
|
||||
36
.pre-commit-config.yaml
Normal file
36
.pre-commit-config.yaml
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v3.2.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
- id: check-added-large-files
|
||||
- repo: https://github.com/batmac/pre-commit-zig
|
||||
rev: v0.3.0
|
||||
hooks:
|
||||
- id: zig-fmt
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: zlint
|
||||
name: Run zlint
|
||||
entry: zlint
|
||||
args: ["--deny-warnings", "--fix"]
|
||||
language: system
|
||||
types: [zig]
|
||||
- repo: https://github.com/batmac/pre-commit-zig
|
||||
rev: v0.3.0
|
||||
hooks:
|
||||
- id: zig-build
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: test
|
||||
name: Run zig build test
|
||||
entry: zig
|
||||
# args: ["build", "coverage", "-Dcoverage-threshold=80"]
|
||||
args: ["build", "test"]
|
||||
language: system
|
||||
types: [file]
|
||||
pass_filenames: false
|
||||
37
build.zig
37
build.zig
|
|
@ -1,4 +1,5 @@
|
|||
const std = @import("std");
|
||||
const lambda_zig = @import("lambda_zig");
|
||||
|
||||
// Although this function looks imperative, note that its job is to
|
||||
// declaratively construct a build graph that will be executed by an external
|
||||
|
|
@ -15,31 +16,32 @@ pub fn build(b: *std.Build) !void {
|
|||
// set a preferred release mode, allowing the user to decide how to optimize.
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "lambda-zig-sample",
|
||||
// In this case the main source file is merely a path, however, in more
|
||||
// complicated build scripts, this could be a generated file.
|
||||
const exe_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
try @import("lambda-zig").lambdaBuildOptions(b, exe);
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "lambda-zig-sample",
|
||||
.root_module = exe_module,
|
||||
});
|
||||
|
||||
const aws_lambda_dep = b.dependency("lambda-zig", .{
|
||||
// Get lambda-zig dependency
|
||||
const lambda_zig_dep = b.dependency("lambda_zig", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const aws_lambda_module = aws_lambda_dep.module("lambda_runtime");
|
||||
exe.root_module.addImport("aws_lambda_runtime", aws_lambda_module);
|
||||
// This declares intent for the executable to be installed into the
|
||||
// standard location when the user invokes the "install" step (the default
|
||||
// step when running `zig build`).
|
||||
|
||||
// Add lambda runtime dependency to the module
|
||||
exe_module.addImport("aws_lambda_runtime", lambda_zig_dep.module("lambda_runtime"));
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
||||
// This *creates* a Run step in the build graph, to be executed when another
|
||||
// step is evaluated that depends on it. The next line below will establish
|
||||
// such a dependency.
|
||||
// Add Lambda build steps (package, deploy, invoke, etc.)
|
||||
try lambda_zig.configureBuild(b, lambda_zig_dep, exe);
|
||||
|
||||
// Run step
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
|
||||
// By making the run step depend on the install step, it will be run from the
|
||||
|
|
@ -62,11 +64,16 @@ pub fn build(b: *std.Build) !void {
|
|||
|
||||
// Creates a step for unit testing. This only builds the test executable
|
||||
// but does not run it.
|
||||
const unit_tests = b.addTest(.{
|
||||
const test_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
test_module.addImport("aws_lambda_runtime", lambda_zig_dep.module("lambda_runtime"));
|
||||
|
||||
const unit_tests = b.addTest(.{
|
||||
.root_module = test_module,
|
||||
});
|
||||
|
||||
const run_unit_tests = b.addRunArtifact(unit_tests);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
.{
|
||||
.name = "lambda-zig",
|
||||
.name = .lambda_zig_sample,
|
||||
.version = "0.1.0",
|
||||
.fingerprint = 0xa392d2e0f8d28528,
|
||||
.minimum_zig_version = "0.15.2",
|
||||
.dependencies = .{
|
||||
.@"lambda-zig" = .{
|
||||
.url = "https://git.lerch.org/lobo/lambda-zig/archive/91149957b58fab30407ffd97abbd3073ad92b39c.tar.gz",
|
||||
.hash = "1220e05a0f97c8a7bcdf426a2228b210937b0105125af179dfbf0243ede75b7da1b2",
|
||||
.lambda_zig = .{
|
||||
.url = "git+https://git.lerch.org/lobo/lambda-zig/#183d2d912c41ca721c8d18e5c258e4472d38db70",
|
||||
.hash = "lambda_zig-0.1.0-_G43_6YQAQD-ahqtf3DQpJroP__spvt4U_uI5TtMZ4Xv",
|
||||
},
|
||||
},
|
||||
.paths = .{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue