Compare commits
No commits in common. "master" and "v1" have entirely different histories.
|
@ -1,49 +0,0 @@
|
||||||
name: GitHub Actions Demo
|
|
||||||
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
|
|
||||||
on: [push]
|
|
||||||
env:
|
|
||||||
ACTIONS_RUNTIME_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
ACTIONS_RUNTIME_URL: https://git.lerch.org/api/actions_pipeline/
|
|
||||||
jobs:
|
|
||||||
do-the-needful:
|
|
||||||
uses: https://git.lerch.org/lobo/actions_test/.github/workflows/zig-build.yaml@master
|
|
||||||
with:
|
|
||||||
zig-version: 0.12.0
|
|
||||||
# - name: Sign
|
|
||||||
# id: sign
|
|
||||||
# uses: https://git.lerch.org/lobo/action-hsm-sign@v1
|
|
||||||
# with:
|
|
||||||
# pin: ${{ secrets.HSM_USER_PIN }}
|
|
||||||
# files: ???
|
|
||||||
# public_key: 'https://emil.lerch.org/serverpublic.pem'
|
|
||||||
# - run: |
|
|
||||||
# echo "Source 0 should be ./bar: ${{ steps.sign.outputs.SOURCE_0 }}"
|
|
||||||
# - run: |
|
|
||||||
# echo "Signature 0 should be ./bar.sig: ${{ steps.sign.outputs.SIG_0 }}"
|
|
||||||
# - run: echo "URL of bar (0) is ${{ steps.sign.outputs.URL_0 }}"
|
|
||||||
# - run: |
|
|
||||||
# echo "Source 1 should be ./foo: ${{ steps.sign.outputs.SOURCE_1 }}"
|
|
||||||
# - run: |
|
|
||||||
# echo "Signature 1 should be ./foo.sig: ${{ steps.sign.outputs.SIG_1 }}"
|
|
||||||
# - run: echo "URL of foo (1) is ${{ steps.sign.outputs.URL_1 }}"
|
|
||||||
# - name: list workflows
|
|
||||||
# if: always()
|
|
||||||
# run: ls ${{ github.workspace }}/.gitea/workflows/
|
|
||||||
# - name: list workspace
|
|
||||||
# if: always()
|
|
||||||
# run: ls ${{ github.workspace }}
|
|
||||||
# Needs gitea 1.20. See https://github.com/go-gitea/gitea/pull/22738
|
|
||||||
# - name: Upload
|
|
||||||
# uses: actions/upload-artifact@v3
|
|
||||||
# with:
|
|
||||||
# name: foobar
|
|
||||||
# path: '*'
|
|
||||||
# - name: Notify
|
|
||||||
# uses: https://git.lerch.org/lobo/action-notify-ntfy@v1
|
|
||||||
# if: always()
|
|
||||||
# with:
|
|
||||||
# host: ${{ secrets.NTFY_HOST }}
|
|
||||||
# topic: ${{ secrets.NTFY_TOPIC }}
|
|
||||||
# user: ${{ secrets.NTFY_USER }}
|
|
||||||
# password: ${{ secrets.NTFY_PASSWORD }}
|
|
||||||
# - run: echo "🍏 This job's status is ${{ job.status }}."
|
|
|
@ -1,67 +1,60 @@
|
||||||
name: GitHub Actions Demo
|
name: GitHub Actions Demo
|
||||||
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
|
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
|
||||||
on: [push]
|
on: [push]
|
||||||
env:
|
|
||||||
ACTIONS_RUNTIME_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
ACTIONS_RUNTIME_URL: https://git.lerch.org/api/actions_pipeline/
|
|
||||||
jobs:
|
jobs:
|
||||||
Explore-GitHub-Actions:
|
Explore-GitHub-Actions:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
env:
|
||||||
shortsha: asdklfjdf
|
PIN: ${{ secrets.HSM_USER_PIN }}
|
||||||
steps:
|
steps:
|
||||||
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event"
|
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
|
||||||
|
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
|
||||||
|
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
|
||||||
|
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
||||||
- name: List files in the repository
|
- name: List files in the repository
|
||||||
run: |
|
run: |
|
||||||
ls ${{ github.workspace }}
|
ls ${{ github.workspace }}
|
||||||
- run: true
|
- run: ls /var/run/
|
||||||
- name: Setup zig
|
- run: echo docker run --rm -it -v /run/pcscd/pcscd.comm:/run/pcscd/pcscd.comm:ro -v "${{ github.workspace }}":/home/user git.lerch.org/lobo/pkcs11:1 -s --id 3 -m SHA256-RSA-PKCS -i foo -o foo.sig --pin env:PIN
|
||||||
uses: https://git.lerch.org/lobo/setup-zig@50b2f79905cf17cf2e8afd09b99dd5dfa64261a0
|
|
||||||
with:
|
|
||||||
version: master
|
|
||||||
# - name: Sign
|
|
||||||
# id: sign
|
|
||||||
# uses: https://git.lerch.org/lobo/action-hsm-sign@v1
|
|
||||||
# with:
|
|
||||||
# pin: ${{ secrets.HSM_USER_PIN }}
|
|
||||||
# files: ???
|
|
||||||
# public_key: 'https://emil.lerch.org/serverpublic.pem'
|
|
||||||
# - run: |
|
|
||||||
# echo "Source 0 should be ./bar: ${{ steps.sign.outputs.SOURCE_0 }}"
|
|
||||||
# - run: |
|
|
||||||
# echo "Signature 0 should be ./bar.sig: ${{ steps.sign.outputs.SIG_0 }}"
|
|
||||||
# - run: echo "URL of bar (0) is ${{ steps.sign.outputs.URL_0 }}"
|
|
||||||
# - run: |
|
|
||||||
# echo "Source 1 should be ./foo: ${{ steps.sign.outputs.SOURCE_1 }}"
|
|
||||||
# - run: |
|
|
||||||
# echo "Signature 1 should be ./foo.sig: ${{ steps.sign.outputs.SIG_1 }}"
|
|
||||||
# - run: echo "URL of foo (1) is ${{ steps.sign.outputs.URL_1 }}"
|
|
||||||
# - name: list workflows
|
|
||||||
# if: always()
|
|
||||||
# run: ls ${{ github.workspace }}/.gitea/workflows/
|
|
||||||
# - name: list workspace
|
|
||||||
# if: always()
|
|
||||||
# run: ls ${{ github.workspace }}
|
|
||||||
# Needs gitea 1.20. See https://github.com/go-gitea/gitea/pull/22738
|
|
||||||
# - name: Upload
|
|
||||||
# uses: actions/upload-artifact@v3
|
|
||||||
# with:
|
|
||||||
# name: foobar
|
|
||||||
# path: '*'
|
|
||||||
# - name: Notify
|
|
||||||
# uses: https://git.lerch.org/lobo/action-notify-ntfy@v1
|
|
||||||
# if: always()
|
|
||||||
# with:
|
|
||||||
# host: ${{ secrets.NTFY_HOST }}
|
|
||||||
# topic: ${{ secrets.NTFY_TOPIC }}
|
|
||||||
# user: ${{ secrets.NTFY_USER }}
|
|
||||||
# password: ${{ secrets.NTFY_PASSWORD }}
|
|
||||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||||
Job-2:
|
- run: true
|
||||||
runs-on: ubuntu-latest
|
- name: Notify
|
||||||
needs: Explore-GitHub-Actions
|
uses: https://git.lerch.org/lobo/action-notify-ntfy@1
|
||||||
steps:
|
if: always()
|
||||||
- name: Show other output
|
with:
|
||||||
run: echo ${{ needs.Explore-GitHub-Actions.outputs.shortsha }}
|
host: ${{ secrets.NTFY_HOST }}
|
||||||
|
topic: ${{ secrets.NTFY_TOPIC }}
|
||||||
|
user: ${{ secrets.NTFY_USER }}
|
||||||
|
password: ${{ secrets.NTFY_PASSWORD }}
|
||||||
|
|
||||||
|
# Sign-Something:
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
# needs: Explore-GitHub-Actions
|
||||||
|
# container:
|
||||||
|
# image: git.lerch.org/lobo/pkcs11:1
|
||||||
|
# env:
|
||||||
|
# PIN: ${{ secrets.HSM_USER_PIN }}
|
||||||
|
# volumes:
|
||||||
|
# /run/pcscd/pcscd.comm:/run/pcscd/pcscd.comm
|
||||||
|
# steps:
|
||||||
|
# - run: -s --id 3 -m SHA256-RSA-PKCS --pin env:PIN -i foo -o foo.sig
|
||||||
|
# - name: Success Notification
|
||||||
|
# if: success()
|
||||||
|
# run: |
|
||||||
|
# curl -u '${{ secrets.NTFY_USER }}:${{ secrets.NTFY_PASSWORD }}' \
|
||||||
|
# -H 'Title: Job Succeeded. ${{ github.repository }}/${{ github.ref }}' \
|
||||||
|
# -H "Tags: +1" \
|
||||||
|
# -d 'Job succeeded. See '$GITHUB_SERVER_URL'/${{ github.repository }}/actions/runs/${{ github.run_number }} for details' \
|
||||||
|
# '${{ secrets.NTFY_HOST }}${{ secrets.NTFY_TOPIC }}'
|
||||||
|
# - name: Failure Notification
|
||||||
|
# if: failure()
|
||||||
|
# run: |
|
||||||
|
# curl -u '${{ secrets.NTFY_USER }}:${{ secrets.NTFY_PASSWORD }}' \
|
||||||
|
# -H "Priority: high" \
|
||||||
|
# -H 'Title: Job FAILED. ${{ github.repository }}/${{ github.ref }}' \
|
||||||
|
# -H "Tags: warning" \
|
||||||
|
# -d 'Job failed. See '$GITHUB_SERVER_URL'/${{ github.repository }}/actions/runs/${{ github.run_number }} for details' \
|
||||||
|
# '${{ secrets.NTFY_HOST }}${{ secrets.NTFY_TOPIC }}'
|
23
.gitea/workflows/notification.yaml
Normal file
23
.gitea/workflows/notification.yaml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
name: GitHub Actions Demo
|
||||||
|
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
|
||||||
|
jobs:
|
||||||
|
Notify:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Success Notification
|
||||||
|
if: success()
|
||||||
|
run: |
|
||||||
|
curl -u '${{ secrets.NTFY_USER }}:${{ secrets.NTFY_PASSWORD }}' \
|
||||||
|
-H 'Title: Job Succeeded. ${{ github.repository }}/${{ github.ref }}' \
|
||||||
|
-H "Tags: +1" \
|
||||||
|
-d 'Job succeeded. See '$GITHUB_SERVER_URL'/${{ github.repository }}/actions/runs/${{ github.run_number }} for details' \
|
||||||
|
'${{ secrets.NTFY_HOST }}${{ secrets.NTFY_TOPIC }}'
|
||||||
|
- name: Failure Notification
|
||||||
|
if: failure()
|
||||||
|
run: |
|
||||||
|
curl -u '${{ secrets.NTFY_USER }}:${{ secrets.NTFY_PASSWORD }}' \
|
||||||
|
-H "Priority: high" \
|
||||||
|
-H 'Title: Job FAILED. ${{ github.repository }}/${{ github.ref }}' \
|
||||||
|
-H "Tags: warning" \
|
||||||
|
-d 'Job failed. See '$GITHUB_SERVER_URL'/${{ github.repository }}/actions/runs/${{ github.run_number }} for details' \
|
||||||
|
'${{ secrets.NTFY_HOST }}${{ secrets.NTFY_TOPIC }}'
|
23
.gitea/workflows/notification/action.yaml
Normal file
23
.gitea/workflows/notification/action.yaml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
name: GitHub Actions Demo
|
||||||
|
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
|
||||||
|
jobs:
|
||||||
|
Notify:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Success Notification
|
||||||
|
if: success()
|
||||||
|
run: |
|
||||||
|
curl -u '${{ secrets.NTFY_USER }}:${{ secrets.NTFY_PASSWORD }}' \
|
||||||
|
-H 'Title: Job Succeeded. ${{ github.repository }}/${{ github.ref }}' \
|
||||||
|
-H "Tags: +1" \
|
||||||
|
-d 'Job succeeded. See '$GITHUB_SERVER_URL'/${{ github.repository }}/actions/runs/${{ github.run_number }} for details' \
|
||||||
|
'${{ secrets.NTFY_HOST }}${{ secrets.NTFY_TOPIC }}'
|
||||||
|
- name: Failure Notification
|
||||||
|
if: failure()
|
||||||
|
run: |
|
||||||
|
curl -u '${{ secrets.NTFY_USER }}:${{ secrets.NTFY_PASSWORD }}' \
|
||||||
|
-H "Priority: high" \
|
||||||
|
-H 'Title: Job FAILED. ${{ github.repository }}/${{ github.ref }}' \
|
||||||
|
-H "Tags: warning" \
|
||||||
|
-d 'Job failed. See '$GITHUB_SERVER_URL'/${{ github.repository }}/actions/runs/${{ github.run_number }} for details' \
|
||||||
|
'${{ secrets.NTFY_HOST }}${{ secrets.NTFY_TOPIC }}'
|
23
.github/workflows/zig-build.yaml
vendored
23
.github/workflows/zig-build.yaml
vendored
|
@ -1,23 +0,0 @@
|
||||||
name: Generic zig build
|
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
inputs:
|
|
||||||
zig-version:
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
# secrets:
|
|
||||||
# token:
|
|
||||||
# required: true
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
steps:
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- name: Setup Zig
|
|
||||||
uses: https://git.lerch.org/lobo/setup-zig@v3
|
|
||||||
with:
|
|
||||||
version: ${{ inputs.zig-version }}
|
|
||||||
- name: Build project
|
|
||||||
run: zig build
|
|
||||||
- name: Run tests
|
|
||||||
run: zig build test --summary all
|
|
91
build.zig
91
build.zig
|
@ -1,91 +0,0 @@
|
||||||
const std = @import("std");
|
|
||||||
|
|
||||||
// Although this function looks imperative, note that its job is to
|
|
||||||
// declaratively construct a build graph that will be executed by an external
|
|
||||||
// runner.
|
|
||||||
pub fn build(b: *std.Build) void {
|
|
||||||
// Standard target options allows the person running `zig build` to choose
|
|
||||||
// what target to build for. Here we do not override the defaults, which
|
|
||||||
// means any target is allowed, and the default is native. Other options
|
|
||||||
// for restricting supported target set are available.
|
|
||||||
const target = b.standardTargetOptions(.{});
|
|
||||||
|
|
||||||
// Standard optimization options allow the person running `zig build` to select
|
|
||||||
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
|
|
||||||
// set a preferred release mode, allowing the user to decide how to optimize.
|
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
|
||||||
|
|
||||||
const lib = b.addStaticLibrary(.{
|
|
||||||
.name = "actions_test",
|
|
||||||
// In this case the main source file is merely a path, however, in more
|
|
||||||
// complicated build scripts, this could be a generated file.
|
|
||||||
.root_source_file = b.path("src/root.zig"),
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
});
|
|
||||||
|
|
||||||
// This declares intent for the library to be installed into the standard
|
|
||||||
// location when the user invokes the "install" step (the default step when
|
|
||||||
// running `zig build`).
|
|
||||||
b.installArtifact(lib);
|
|
||||||
|
|
||||||
const exe = b.addExecutable(.{
|
|
||||||
.name = "actions_test",
|
|
||||||
.root_source_file = b.path("src/main.zig"),
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
});
|
|
||||||
|
|
||||||
// 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`).
|
|
||||||
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.
|
|
||||||
const run_cmd = b.addRunArtifact(exe);
|
|
||||||
|
|
||||||
// By making the run step depend on the install step, it will be run from the
|
|
||||||
// installation directory rather than directly from within the cache directory.
|
|
||||||
// This is not necessary, however, if the application depends on other installed
|
|
||||||
// files, this ensures they will be present and in the expected location.
|
|
||||||
run_cmd.step.dependOn(b.getInstallStep());
|
|
||||||
|
|
||||||
// This allows the user to pass arguments to the application in the build
|
|
||||||
// command itself, like this: `zig build run -- arg1 arg2 etc`
|
|
||||||
if (b.args) |args| {
|
|
||||||
run_cmd.addArgs(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This creates a build step. It will be visible in the `zig build --help` menu,
|
|
||||||
// and can be selected like this: `zig build run`
|
|
||||||
// This will evaluate the `run` step rather than the default, which is "install".
|
|
||||||
const run_step = b.step("run", "Run the app");
|
|
||||||
run_step.dependOn(&run_cmd.step);
|
|
||||||
|
|
||||||
// Creates a step for unit testing. This only builds the test executable
|
|
||||||
// but does not run it.
|
|
||||||
const lib_unit_tests = b.addTest(.{
|
|
||||||
.root_source_file = b.path("src/root.zig"),
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
});
|
|
||||||
|
|
||||||
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
|
|
||||||
|
|
||||||
const exe_unit_tests = b.addTest(.{
|
|
||||||
.root_source_file = b.path("src/main.zig"),
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
});
|
|
||||||
|
|
||||||
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
|
|
||||||
|
|
||||||
// Similar to creating the run step earlier, this exposes a `test` step to
|
|
||||||
// the `zig build --help` menu, providing a way for the user to request
|
|
||||||
// running the unit tests.
|
|
||||||
const test_step = b.step("test", "Run unit tests");
|
|
||||||
test_step.dependOn(&run_lib_unit_tests.step);
|
|
||||||
test_step.dependOn(&run_exe_unit_tests.step);
|
|
||||||
}
|
|
|
@ -1,67 +0,0 @@
|
||||||
.{
|
|
||||||
.name = "actions_test",
|
|
||||||
// This is a [Semantic Version](https://semver.org/).
|
|
||||||
// In a future version of Zig it will be used for package deduplication.
|
|
||||||
.version = "0.0.0",
|
|
||||||
|
|
||||||
// This field is optional.
|
|
||||||
// This is currently advisory only; Zig does not yet do anything
|
|
||||||
// with this value.
|
|
||||||
//.minimum_zig_version = "0.11.0",
|
|
||||||
|
|
||||||
// This field is optional.
|
|
||||||
// Each dependency must either provide a `url` and `hash`, or a `path`.
|
|
||||||
// `zig build --fetch` can be used to fetch all dependencies of a package, recursively.
|
|
||||||
// Once all dependencies are fetched, `zig build` no longer requires
|
|
||||||
// internet connectivity.
|
|
||||||
.dependencies = .{
|
|
||||||
// See `zig fetch --save <url>` for a command-line interface for adding dependencies.
|
|
||||||
//.example = .{
|
|
||||||
// // When updating this field to a new URL, be sure to delete the corresponding
|
|
||||||
// // `hash`, otherwise you are communicating that you expect to find the old hash at
|
|
||||||
// // the new URL.
|
|
||||||
// .url = "https://example.com/foo.tar.gz",
|
|
||||||
//
|
|
||||||
// // This is computed from the file contents of the directory of files that is
|
|
||||||
// // obtained after fetching `url` and applying the inclusion rules given by
|
|
||||||
// // `paths`.
|
|
||||||
// //
|
|
||||||
// // This field is the source of truth; packages do not come from a `url`; they
|
|
||||||
// // come from a `hash`. `url` is just one of many possible mirrors for how to
|
|
||||||
// // obtain a package matching this `hash`.
|
|
||||||
// //
|
|
||||||
// // Uses the [multihash](https://multiformats.io/multihash/) format.
|
|
||||||
// .hash = "...",
|
|
||||||
//
|
|
||||||
// // When this is provided, the package is found in a directory relative to the
|
|
||||||
// // build root. In this case the package's hash is irrelevant and therefore not
|
|
||||||
// // computed. This field and `url` are mutually exclusive.
|
|
||||||
// .path = "foo",
|
|
||||||
|
|
||||||
// // When this is set to `true`, a package is declared to be lazily
|
|
||||||
// // fetched. This makes the dependency only get fetched if it is
|
|
||||||
// // actually used.
|
|
||||||
// .lazy = false,
|
|
||||||
//},
|
|
||||||
},
|
|
||||||
|
|
||||||
// Specifies the set of files and directories that are included in this package.
|
|
||||||
// Only files and directories listed here are included in the `hash` that
|
|
||||||
// is computed for this package.
|
|
||||||
// Paths are relative to the build root. Use the empty string (`""`) to refer to
|
|
||||||
// the build root itself.
|
|
||||||
// A directory listed here means that all files within, recursively, are included.
|
|
||||||
.paths = .{
|
|
||||||
// This makes *all* files, recursively, included in this package. It is generally
|
|
||||||
// better to explicitly list the files and directories instead, to insure that
|
|
||||||
// fetching from tarballs, file system paths, and version control all result
|
|
||||||
// in the same contents hash.
|
|
||||||
"",
|
|
||||||
// For example...
|
|
||||||
//"build.zig",
|
|
||||||
//"build.zig.zon",
|
|
||||||
//"src",
|
|
||||||
//"LICENSE",
|
|
||||||
//"README.md",
|
|
||||||
},
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
hello world!
|
|
24
src/main.zig
24
src/main.zig
|
@ -1,24 +0,0 @@
|
||||||
const std = @import("std");
|
|
||||||
|
|
||||||
pub fn main() !void {
|
|
||||||
// Prints to stderr (it's a shortcut based on `std.io.getStdErr()`)
|
|
||||||
std.debug.print("All your {s} are belong to us.\n", .{"codebase"});
|
|
||||||
|
|
||||||
// stdout is for the actual output of your application, for example if you
|
|
||||||
// are implementing gzip, then only the compressed bytes should be sent to
|
|
||||||
// stdout, not any debugging messages.
|
|
||||||
const stdout_file = std.io.getStdOut().writer();
|
|
||||||
var bw = std.io.bufferedWriter(stdout_file);
|
|
||||||
const stdout = bw.writer();
|
|
||||||
|
|
||||||
try stdout.print("Run `zig build test` to run the tests.\n", .{});
|
|
||||||
|
|
||||||
try bw.flush(); // don't forget to flush!
|
|
||||||
}
|
|
||||||
|
|
||||||
test "simple test" {
|
|
||||||
var list = std.ArrayList(i32).init(std.testing.allocator);
|
|
||||||
defer list.deinit(); // try commenting this out and see if zig detects the memory leak!
|
|
||||||
try list.append(42);
|
|
||||||
try std.testing.expectEqual(@as(i32, 42), list.pop());
|
|
||||||
}
|
|
10
src/root.zig
10
src/root.zig
|
@ -1,10 +0,0 @@
|
||||||
const std = @import("std");
|
|
||||||
const testing = std.testing;
|
|
||||||
|
|
||||||
export fn add(a: i32, b: i32) i32 {
|
|
||||||
return a + b;
|
|
||||||
}
|
|
||||||
|
|
||||||
test "basic add functionality" {
|
|
||||||
try testing.expect(add(3, 7) == 10);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user