Compare commits
No commits in common. "master" and "zig-develop" have entirely different histories.
master
...
zig-develo
5 changed files with 18 additions and 72 deletions
8
.envrc
8
.envrc
|
@ -1,8 +0,0 @@
|
|||
# vi: ft=sh
|
||||
# shellcheck shell=bash
|
||||
|
||||
if ! has zvm_direnv_version || ! zvm_direnv_version 2.0.0; then
|
||||
source_url "https://git.lerch.org/lobo/zvm-direnv/raw/tag/2.0.0/direnvrc" "sha256-8Umzxj32hFU6G0a7Wrq0KTNDQ8XEuje2A3s2ljh/hFY="
|
||||
fi
|
||||
|
||||
use zig 0.14.0
|
|
@ -9,20 +9,17 @@ jobs:
|
|||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Zig
|
||||
uses: https://github.com/mlugg/setup-zig@v1.2.1
|
||||
- uses: actions/checkout@v4
|
||||
- uses: elerch/setup-zig@v3
|
||||
with:
|
||||
version: 0.14.0
|
||||
- name: Restore Zig caches
|
||||
uses: https://github.com/Hanaasagi/zig-action-cache@3954aae427f8b05914e08dfd79f15e1f2e435929
|
||||
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: https://git.lerch.org/lobo/action-notify-ntfy@v2
|
||||
uses: elerch/action-notify-ntfy@v2.github
|
||||
if: always() && env.GITEA_ACTIONS == 'true'
|
||||
with:
|
||||
host: ${{ secrets.NTFY_HOST }}
|
|
@ -50,7 +50,3 @@ pub fn build(b: *std.Build) void {
|
|||
const test_step = b.step("test", "Run library tests");
|
||||
test_step.dependOn(&run_main_tests.step);
|
||||
}
|
||||
|
||||
// define AwsProtocol to support usage within build.zig as an import
|
||||
const smithy = @import("src/smithy.zig");
|
||||
pub const AwsProtocol = smithy.AwsProtocol;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
.{
|
||||
.name = .smithy,
|
||||
.name = "smithy",
|
||||
.version = "1.0.0",
|
||||
.fingerprint = 0xccfd3d0281810cb8,
|
||||
.paths = .{
|
||||
"build.zig",
|
||||
"build.zig.zon",
|
||||
"src",
|
||||
"README.md",
|
||||
"LICENSE",
|
||||
"build.zig",
|
||||
"build.zig.zon",
|
||||
"src",
|
||||
"README.md",
|
||||
"LICENSE",
|
||||
},
|
||||
|
||||
.dependencies = .{},
|
||||
.dependencies = .{
|
||||
},
|
||||
}
|
||||
|
|
|
@ -235,7 +235,7 @@ const Shape = union(ShapeType) {
|
|||
traits: []Trait,
|
||||
},
|
||||
service: struct {
|
||||
version: ?[]const u8, // A version is optional in Smithy. https://smithy.io/2.0/spec/service-types.html
|
||||
version: []const u8,
|
||||
operations: [][]const u8,
|
||||
resources: [][]const u8,
|
||||
traits: []Trait,
|
||||
|
@ -482,7 +482,7 @@ fn getShape(allocator: std.mem.Allocator, shape: std.json.Value) SmithyParseErro
|
|||
if (std.mem.eql(u8, shape_type, "service"))
|
||||
return Shape{
|
||||
.service = .{
|
||||
.version = if (shape.object.get("version")) |v| v.string else null,
|
||||
.version = shape.object.get("version").?.string,
|
||||
.operations = if (shape.object.get("operations")) |ops|
|
||||
try parseTargetList(allocator, ops.array)
|
||||
else
|
||||
|
@ -789,7 +789,6 @@ fn getTrait(trait_type: []const u8, value: std.json.Value) SmithyParseError!?Tra
|
|||
\\smithy.api#timestampFormat
|
||||
\\smithy.api#xmlAttribute
|
||||
\\smithy.api#xmlFlattened
|
||||
\\smithy.api#requestCompression
|
||||
\\smithy.waiters#waitable
|
||||
\\smithy.rules#endpointTests
|
||||
\\smithy.api#input
|
||||
|
@ -805,24 +804,17 @@ fn getTrait(trait_type: []const u8, value: std.json.Value) SmithyParseError!?Tra
|
|||
\\smithy.api#recommended
|
||||
\\smithy.api#httpBearerAuth
|
||||
\\smithy.api#nestedProperties
|
||||
\\smithy.api#private
|
||||
\\smithy.rules#endpointRuleSet
|
||||
\\smithy.rules#contextParam
|
||||
\\smithy.rules#clientContextParams
|
||||
\\smithy.rules#staticContextParams
|
||||
\\smithy.rules#operationContextParams
|
||||
\\smithy.test#smokeTests
|
||||
\\aws.cloudformation#cfnResource
|
||||
\\aws.cloudformation#cfnMutability
|
||||
\\aws.cloudformation#cfnExcludeProperty
|
||||
\\aws.cloudformation#cfnAdditionalIdentifier
|
||||
\\aws.endpoints#standardPartitionalEndpoints
|
||||
\\aws.endpoints#dualStackOnlyEndpoints
|
||||
\\aws.endpoints#standardRegionalEndpoints
|
||||
\\aws.iam#actionPermissionDescription
|
||||
\\aws.iam#requiredActions
|
||||
\\aws.iam#conditionKeys
|
||||
\\aws.iam#conditionKeyValue
|
||||
\\aws.iam#iamResource
|
||||
\\aws.iam#iamAction
|
||||
\\aws.iam#supportedPrincipalTypes
|
||||
|
@ -901,37 +893,6 @@ fn read_file_to_string(allocator: std.mem.Allocator, file_name: []const u8, max_
|
|||
const test_data: []const u8 = @embedFile("test.json");
|
||||
const intrinsic_type_count: usize = 15; // 15 intrinsic types are added to every model (see shapes() function)
|
||||
|
||||
test "parse service without version" {
|
||||
const test_string =
|
||||
\\ {
|
||||
\\ "smithy": "1.0",
|
||||
\\ "shapes": {
|
||||
\\ "com.amazonaws.sts#AWSSecurityTokenServiceV20110615": {
|
||||
\\ "type": "service",
|
||||
\\ "operations": [
|
||||
\\ {
|
||||
\\ "target": "op"
|
||||
\\ }
|
||||
\\ ]
|
||||
\\ }
|
||||
\\ }
|
||||
\\ }
|
||||
\\
|
||||
\\
|
||||
;
|
||||
|
||||
const allocator = std.testing.allocator;
|
||||
const model = try parse(allocator, test_string);
|
||||
defer model.deinit();
|
||||
try expect(std.mem.eql(u8, model.version, "1.0"));
|
||||
|
||||
try std.testing.expectEqual(intrinsic_type_count + 1, model.shapes.len);
|
||||
try std.testing.expectEqualStrings("com.amazonaws.sts#AWSSecurityTokenServiceV20110615", model.shapes[0].id);
|
||||
try std.testing.expectEqualStrings("com.amazonaws.sts", model.shapes[0].namespace);
|
||||
try std.testing.expectEqualStrings("AWSSecurityTokenServiceV20110615", model.shapes[0].name);
|
||||
try std.testing.expect(model.shapes[0].member == null);
|
||||
try std.testing.expect(model.shapes[0].shape.service.version == null);
|
||||
}
|
||||
test "parse string" {
|
||||
const test_string =
|
||||
\\ {
|
||||
|
@ -962,7 +923,7 @@ test "parse string" {
|
|||
try std.testing.expectEqualStrings("com.amazonaws.sts", model.shapes[0].namespace);
|
||||
try std.testing.expectEqualStrings("AWSSecurityTokenServiceV20110615", model.shapes[0].name);
|
||||
try std.testing.expect(model.shapes[0].member == null);
|
||||
try std.testing.expectEqualStrings("2011-06-15", model.shapes[0].shape.service.version.?);
|
||||
try std.testing.expectEqualStrings("2011-06-15", model.shapes[0].shape.service.version);
|
||||
}
|
||||
test "parse shape with member" {
|
||||
const test_string =
|
||||
|
@ -992,7 +953,7 @@ test "parse shape with member" {
|
|||
try std.testing.expectEqualStrings("com.amazonaws.sts#AWSSecurityTokenServiceV20110615$member", model.shapes[0].id);
|
||||
try std.testing.expectEqualStrings("com.amazonaws.sts", model.shapes[0].namespace);
|
||||
try std.testing.expectEqualStrings("AWSSecurityTokenServiceV20110615", model.shapes[0].name);
|
||||
try std.testing.expectEqualStrings("2011-06-15", model.shapes[0].shape.service.version.?);
|
||||
try std.testing.expectEqualStrings("2011-06-15", model.shapes[0].shape.service.version);
|
||||
try std.testing.expectEqualStrings("member", model.shapes[0].member.?);
|
||||
}
|
||||
test "parse file" {
|
||||
|
@ -1017,7 +978,7 @@ test "parse file" {
|
|||
try std.testing.expectEqualStrings("com.amazonaws.sts#AWSSecurityTokenServiceV20110615", svc.id);
|
||||
try std.testing.expectEqualStrings("com.amazonaws.sts", svc.namespace);
|
||||
try std.testing.expectEqualStrings("AWSSecurityTokenServiceV20110615", svc.name);
|
||||
try std.testing.expectEqualStrings("2011-06-15", svc.shape.service.version.?);
|
||||
try std.testing.expectEqualStrings("2011-06-15", svc.shape.service.version);
|
||||
// Should be 6, but we don't handle title or xml namespace
|
||||
try std.testing.expectEqual(@as(usize, 4), svc.shape.service.traits.len);
|
||||
try std.testing.expectEqual(@as(usize, 8), svc.shape.service.operations.len);
|
||||
|
|
Loading…
Add table
Reference in a new issue