Skip to content

Commit

Permalink
remove CLA check in CI (#60)
Browse files Browse the repository at this point in the history
* remove CLA check in CI

* format code
  • Loading branch information
Yoorkin authored Sep 23, 2024
1 parent 2a9368f commit ed9ca70
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 73 deletions.
30 changes: 0 additions & 30 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,6 @@ on:
pull_request:

jobs:
cla-check:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
outputs:
cla-signed: ${{ steps.cla-check-step.outputs.cla-signed }}
steps:
- uses: actions/checkout@v4
- name: CLA check
id: cla-check-step
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_AUTHOR=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }} \
| jq -r '.user.login')
echo "The PR author is $PR_AUTHOR"
EMAIL=$(git log -1 --pretty=format:'%ae')
echo "Commit author email: $EMAIL"
CLA_RESPONSE=$(curl -s "https://mooncakes.io/api/v0/cla/check?gh_username=$PR_AUTHOR&email=$EMAIL")
echo "CLA check response: $CLA_RESPONSE"
SIGNED=$(echo $CLA_RESPONSE | jq -r '.signed')
echo "cla-signed=$SIGNED" >> $GITHUB_ENV
echo "If you have any questions about the CLA result, please contact us."
if [ "$SIGNED" != "true" ]; then
echo "CLA is not signed."
exit 1
else
echo "CLA is signed."
fi
build:
strategy:
matrix:
Expand Down
20 changes: 9 additions & 11 deletions crypto/sha1.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,27 @@ pub fn sha1(input : Bytes) -> Bytes {
let words = FixedArray::make(80, 0)
for i = 0; i < 16; i = i + 1 {
let slice_start = chunk * bytes_per_chunk + i * 4
words[i] = bytes[slice_start]
.to_int()
.lsl(24)
.lor(bytes[slice_start + 1].to_int().lsl(16))
.lor(bytes[slice_start + 2].to_int().lsl(8))
.lor(bytes[slice_start + 3].to_int())
words[i] = bytes[slice_start].to_int().lsl(24) |
bytes[slice_start + 1].to_int().lsl(16) |
bytes[slice_start + 2].to_int().lsl(8) |
bytes[slice_start + 3].to_int()
}
for i = 16; i < 80; i = i + 1 {
words[i] = rotate_left(
words[i - 3].lxor(words[i - 8]).lxor(words[i - 14]).lxor(words[i - 16]),
words[i - 3] ^ words[i - 8] ^ words[i - 14] ^ words[i - 16],
1,
)
}
let v = h.copy()
for i = 0; i < 80; i = i + 1 {
let (f, k) = if i < 20 {
(v[1].land(v[2]).lor(v[1].lnot().land(v[3])), 0x5A827999)
((v[1] & v[2]) | (v[1].lnot() & v[3]), 0x5A827999)
} else if i < 40 {
(v[1].lxor(v[2].lxor(v[3])), 0x6ED9EBA1)
(v[1] ^ (v[2] ^ v[3]), 0x6ED9EBA1)
} else if i < 60 {
(v[1].land(v[2]).lor(v[1].land(v[3])).lor(v[2].land(v[3])), 0x8F1BBCDC)
((v[1] & v[2]) | (v[1] & v[3]) | (v[2] & v[3]), 0x8F1BBCDC)
} else {
(v[1].lxor(v[2].lxor(v[3])), 0xCA62C1D6)
(v[1] ^ (v[2] ^ v[3]), 0xCA62C1D6)
}
let temp = rotate_left(v[0], 5) + f + v[4] + k + words[i]
v[4] = v[3]
Expand Down
24 changes: 12 additions & 12 deletions crypto/sha256.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,22 @@ fn transform(
w[index] = bytes_u8_to_u32be(data, i=4 * index + offset)
}
for index = 16; index < 64; index = index + 1 {
let sigma_0 = rotate_right_u(w[index - 15], 7)
.lxor(rotate_right_u(w[index - 15], 18))
.lxor(w[index - 15].shr(3))
let sigma_1 = rotate_right_u(w[index - 2], 17)
.lxor(rotate_right_u(w[index - 2], 19))
.lxor(w[index - 2].shr(10))
let sigma_0 = rotate_right_u(w[index - 15], 7) ^
rotate_right_u(w[index - 15], 18) ^
(w[index - 15] >> 3)
let sigma_1 = rotate_right_u(w[index - 2], 17) ^
rotate_right_u(w[index - 2], 19) ^
(w[index - 2] >> 10)
w[index] = w[index - 16] + sigma_0 + w[index - 7] + sigma_1
}
for index = 0; index < 64; index = index + 1 {
let big_sigma_1 = rotate_right_u(e, 6)
.lxor(rotate_right_u(e, 11))
.lxor(rotate_right_u(e, 25))
let big_sigma_1 = rotate_right_u(e, 6) ^
rotate_right_u(e, 11) ^
rotate_right_u(e, 25)
let t_1 = h + big_sigma_1 + gg_1(e, f, g) + sha256_t[index] + w[index]
let big_sigma_0 = rotate_right_u(a, 2)
.lxor(rotate_right_u(a, 13))
.lxor(rotate_right_u(a, 22))
let big_sigma_0 = rotate_right_u(a, 2) ^
rotate_right_u(a, 13) ^
rotate_right_u(a, 22)
let t_2 = big_sigma_0 + ff_1(a, b, c)
h = g
g = f
Expand Down
6 changes: 3 additions & 3 deletions crypto/utils.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ pub fn bytes_to_hex_string(input : Bytes) -> String {
let mut ret = ""
for i = input.length() - 1; i >= 0; i = i - 1 {
let byte = input[i]
let high = byte.to_int().lsr(4).land(0xf)
let low = byte.to_int().land(0xf)
let high = byte.to_int().lsr(4) & 0xf
let low = byte.to_int() & 0xf
let high_char = hex_digits[high]
let low_char = hex_digits[low]
ret = high_char + low_char + ret
Expand Down Expand Up @@ -106,7 +106,7 @@ fn arr_u32_to_u8be(x : Iter[UInt]) -> Bytes {
/// rotate a Int `x` left by `n` bit(s)

fn rotate_left(x : Int, n : Int) -> Int {
x.lsl(n).lor(x.lsr(32 - n))
x.lsl(n) | x.lsr(32 - n)
}

/// rotate a UInt `x` left by `n` bit(s)
Expand Down
6 changes: 3 additions & 3 deletions json5/lex_string.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,17 @@ fn lex_hex_digits(ctx : ParseContext, n : Int) -> Int!ParseError {
match read_char(ctx) {
Some(c) =>
if c >= 'A' {
let d = c.to_int().land((32).lnot()) - 'A'.to_int() + 10
let d = (c.to_int() & (32).lnot()) - 'A'.to_int() + 10
if d > 15 {
invalid_char!(ctx, shift=-1)
}
r = r.lsl(4).lor(d)
r = r.lsl(4) | d
} else if c >= '0' {
let d = c.to_int() - '0'.to_int()
if d > 9 {
invalid_char!(ctx, shift=-1)
}
r = r.lsl(4).lor(d)
r = r.lsl(4) | d
} else {
invalid_char!(ctx, shift=-1)
}
Expand Down
2 changes: 1 addition & 1 deletion json5/util.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn invalid_char[X](ctx : ParseContext, ~shift : Int = 0) -> X!ParseError {

fn hex_digit_to_int(c : Char) -> Int {
if c >= 'A' {
c.to_int().land((32).lnot()) - 'A'.to_int() + 10
(c.to_int() & (32).lnot()) - 'A'.to_int() + 10
} else {
c.to_int() - '0'.to_int()
}
Expand Down
2 changes: 1 addition & 1 deletion time/util.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ fn checked_mul_int(x : Int, y : Int) -> Int!Error {
fn checked_add_int64(x : Int64, y : Int64) -> Int64!Error {
let r = x + y
// Overflow iff both arguments have the opposite sign of the result
if x.lxor(r).land(y.lxor(r)) < 0L {
if ((x ^ r) & (y ^ r)) < 0L {
int64_overflow_err!()
} else {
r
Expand Down
2 changes: 1 addition & 1 deletion uuid/ops.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
// limitations under the License.

pub fn hash(self : UUID) -> Int {
Hash::hash(self.lo).lxor(Hash::hash(self.hi))
Hash::hash(self.lo) ^ Hash::hash(self.hi)
}
8 changes: 4 additions & 4 deletions uuid/uuid.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ pub fn from_bytes(bytes : Bytes) -> UUID!Error {
}
// XXX: this is ideally Int64::from_bytes() (needs a cheap slicing method)
let hi = for rv = 0L, i = 0; i < 8; {
continue rv.lor(bytes[i].to_int64().lsl((7 - i) * 8)), i + 1
continue rv | bytes[i].to_int64().lsl((7 - i) * 8), i + 1
} else {
rv
}
let lo = for rv = 0L, i = 8; i < 16; {
continue rv.lor(bytes[i].to_int64().lsl((15 - i) * 8)), i + 1
continue rv | bytes[i].to_int64().lsl((15 - i) * 8), i + 1
} else {
rv
}
Expand Down Expand Up @@ -129,7 +129,7 @@ pub fn from_hex(hex : String) -> UUID!Error {
continue hi, i + 1, n
} else {
let d = hex_char_to_int64!(c)
continue hi.lor(d.lsl((15 - n) * 4)), i + 1, n + 1
continue hi | d.lsl((15 - n) * 4), i + 1, n + 1
}
} else {
(hi, i)
Expand All @@ -143,7 +143,7 @@ pub fn from_hex(hex : String) -> UUID!Error {
continue lo, i + 1, n
} else {
let d = hex_char_to_int64!(c)
continue lo.lor(d.lsl((15 - n) * 4)), i + 1, n + 1
continue lo | d.lsl((15 - n) * 4), i + 1, n + 1
}
} else {
(lo, i)
Expand Down
17 changes: 10 additions & 7 deletions uuid/variant.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ fn to_int64(self : Version) -> Int64 {

/// Retrieves the variant of the UUID.
pub fn variant(self : UUID) -> Variant {
if self.lo.land(0x8000L.lsl(48)) == 0L {
if (self.lo & 0x8000L.lsl(48)) == 0L {
ReservedNCS
} else if self.lo.land(0x4000L.lsl(48)) == 0L {
RFC4122(from_int64(self.hi.lsr(12).land(0xfL)))
} else if self.lo.land(0x2000L.lsl(48)) == 0L {
} else if (self.lo & 0x4000L.lsl(48)) == 0L {
RFC4122(from_int64(self.hi.lsr(12) & 0xfL))
} else if (self.lo & 0x2000L.lsl(48)) == 0L {
ReservedMicrosoft
} else {
ReservedFuture
Expand All @@ -86,9 +86,12 @@ pub fn version(self : UUID) -> Version? {
pub fn as_version(self : UUID, version : Version) -> UUID {
let { hi, lo } = self
// Set the variant to RFC 4122.
let lo = lo.land(0xc000L.lsl(48).lnot()).lor(0x8000L.lsl(48))
// Set the version number.
let hi = hi.land(0xf000L.lnot()).lor(version.to_int64().lsl(12))
let lo = (lo & 0xc000L.lsl(48).lnot()) | 0x8000L.lsl(48)
let hi = (
// Set the version number.
hi & 0xf000L.lnot()
) |
version.to_int64().lsl(12)
{ hi, lo }
}

Expand Down

0 comments on commit ed9ca70

Please sign in to comment.