Skip to content

Commit

Permalink
Merge branch 'main' into iot
Browse files Browse the repository at this point in the history
  • Loading branch information
sbSteveK committed Oct 31, 2024
2 parents 3b05289 + 93ac601 commit cbc4bcb
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 17 deletions.
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ body:
description: What is the problem? A clear and concise description of the bug.
validations:
required: true
- type: checkboxes
id: regression
attributes:
label: Regression Issue
description: What is a regression? If it worked in a previous version but doesn't in the latest version, it's considered a regression. In this case, please provide specific version number in the report.
options:
- label: Select this option if this issue appears to be a regression.
required: false
- type: textarea
id: expected
attributes:
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/issue-regression-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Apply potential regression label on issues
name: issue-regression-label
on:
issues:
types: [opened, edited]
jobs:
add-regression-label:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Fetch template body
id: check_regression
uses: actions/github-script@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TEMPLATE_BODY: ${{ github.event.issue.body }}
with:
script: |
const regressionPattern = /\[x\] Select this option if this issue appears to be a regression\./i;
const template = `${process.env.TEMPLATE_BODY}`
const match = regressionPattern.test(template);
core.setOutput('is_regression', match);
- name: Manage regression label
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${{ steps.check_regression.outputs.is_regression }}" == "true" ]; then
gh issue edit ${{ github.event.issue.number }} --add-label "potential-regression" -R ${{ github.repository }}
else
gh issue edit ${{ github.event.issue.number }} --remove-label "potential-regression" -R ${{ github.repository }}
fi
36 changes: 25 additions & 11 deletions Source/AwsCommonRuntimeKit/crt/Checksums.swift
Original file line number Diff line number Diff line change
@@ -1,29 +1,43 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0.

import struct Foundation.Data
import AwsCChecksums

import struct Foundation.Data

extension Data {

/// Computes the CRC32 over data.
/// - Parameter previousCrc32: Pass 0 in the previousCrc32 parameter as an initial value unless continuing to update a running crc in a subsequent call.
public func computeCRC32(previousCrc32: UInt32 = 0) -> UInt32 {
self.withUnsafeBytes { bufferPointer in
return aws_checksums_crc32(bufferPointer.baseAddress?.assumingMemoryBound(to: UInt8.self),
Int32(count),
previousCrc32)
return aws_checksums_crc32_ex(
bufferPointer.baseAddress?.assumingMemoryBound(to: UInt8.self),
count,
previousCrc32)
}
}

/// Computes the crc32c over data.
/// - Parameter previousCrc32c: Pass 0 in the previousCrc32c parameter as an initial value unless continuing to update a running crc in a subsequent call.
public func computeCRC32C(previousCrc32c: UInt32 = 0) -> UInt32 {
self.withUnsafeBytes { bufferPointer in
return aws_checksums_crc32c(bufferPointer.baseAddress?.assumingMemoryBound(to: UInt8.self),
Int32(count),
previousCrc32c)
}
return aws_checksums_crc32c_ex(
bufferPointer.baseAddress?.assumingMemoryBound(to: UInt8.self),
count,
previousCrc32c)
}
}


/// Computes the CRC64NVME over data.
/// - Parameter previousCrc64Nvme: Pass 0 in the previousCrc64Nvme parameter as an initial value unless continuing to update a running crc in a subsequent call.
public func computeCRC64Nvme(previousCrc64Nvme: UInt64 = 0) -> UInt64 {
self.withUnsafeBytes { bufferPointer in
return aws_checksums_crc64nvme_ex(
bufferPointer.baseAddress?.assumingMemoryBound(to: UInt8.self),
count,
previousCrc64Nvme)
}
}

}
6 changes: 6 additions & 0 deletions Test/AwsCommonRuntimeKitTests/crt/ChecksumsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@ class ChecksumsTests: XCBaseTestCase {
XCTAssertEqual("Hello".data(using: .utf8)!.computeCRC32C(), 2178485787)
XCTAssertEqual("{\"foo\":\"base64 encoded sha1 checksum\"}".data(using: .utf8)!.computeCRC32C(), 3565301023)
}

func testCRC64Nvme() throws {
XCTAssertEqual("".data(using: .utf8)!.computeCRC64Nvme(), 0)
XCTAssertEqual(Data(count: 32).computeCRC64Nvme(), 0xCF3473434D4ECF3B)
XCTAssertEqual(Data(Array(0..<32)).computeCRC64Nvme(), 0xB9D9D4A8492CBD7F)
}

}
2 changes: 1 addition & 1 deletion aws-common-runtime/aws-c-http
5 changes: 5 additions & 0 deletions aws-common-runtime/config/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Helpers for swift to build the aws-common-runtime packages

It contains:
* a symlink to point s2n/unstable/cleanup.h to api/unstable/cleanup.h for building s2n with the other aws-common-runtime packages.
* `aws/common/config.h`, because cmake will run for swift build. Set the config.h separately.
1 change: 1 addition & 0 deletions aws-common-runtime/config/s2n
2 changes: 1 addition & 1 deletion aws-common-runtime/s2n
Submodule s2n updated 121 files

0 comments on commit cbc4bcb

Please sign in to comment.