Skip to content

Commit

Permalink
CI checks on license and metadata (#552)
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth authored Oct 16, 2024
1 parent e0beb55 commit 6bfcdc4
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 10 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,6 @@ jobs:
working-directory: ./${{ matrix.crate }}
run: cargo --locked check

copyright:
if: github.repository_owner == 'aws'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Check
run: |
./scripts/tools/copyright_check.sh
semver-checks:
if: github.repository_owner == 'aws'
runs-on: ubuntu-latest
Expand Down Expand Up @@ -312,3 +302,13 @@ jobs:
VERSION=$(scripts/tools/cargo-dig.rs aws-lc-rs/Cargo.toml -v)
LINKS_LINE=$(echo links = \"aws_lc_rs_${VERSION//./_}_sys\")
grep "${LINKS_LINE}" aws-lc-rs/Cargo.toml
- name: aws-lc-sys links
run: |
VERSION=$(scripts/tools/cargo-dig.rs aws-lc-sys/Cargo.toml -v)
LINKS_LINE=$(echo links = \"aws_lc_${VERSION//./_}\")
grep "${LINKS_LINE}" aws-lc-sys/Cargo.toml
- name: aws-lc-fips-sys links
run: |
VERSION=$(scripts/tools/cargo-dig.rs aws-lc-fips-sys/Cargo.toml -v)
LINKS_LINE=$(echo links = \"aws_lc_fips_${VERSION//./_}\")
grep "${LINKS_LINE}" aws-lc-fips-sys/Cargo.toml
70 changes: 70 additions & 0 deletions .github/workflows/misc-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Miscellaneous test jobs
on:
push:
branches: [ '*' ]
pull_request:
branches: [ '*' ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
copyright:
if: github.repository_owner == 'aws'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Check
run: |
./scripts/tools/copyright_check.sh
assert-license-statement-in-pr-description:
if: github.repository_owner == 'aws'
runs-on: ubuntu-latest

steps:
- name: Install jq
run: |
sudo apt-get update -o Acquire::Languages=none -o Acquire::Translation=none
sudo apt-get install -y jq
- name: Check PR description
run: |
# License statement we want present.
LICENSE_STATEMENT="By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license."
# Fetches the PR description.
PR_DESCRIPTION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} | jq -r .body)
printf "PR description:\n%s" "${PR_DESCRIPTION}"
echo ""
echo ""
printf "Must contain:\n%s" "${LICENSE_STATEMENT}"
echo ""
echo ""
# Normalize line endings (convert CRLF to LF)
PR_DESCRIPTION=$(echo "${PR_DESCRIPTION}" | tr -d '\r')
# Escape quotes in PR description
PR_DESCRIPTION=$(echo "${PR_DESCRIPTION}" | sed 's/"/\\"/g; s/'"'"'/\\'"'"'/g')
# Remove all spaces and tabs
PR_DESCRIPTION=$(echo "${PR_DESCRIPTION}" | tr -d ' \t')
LICENSE_STATEMENT=$(echo "${LICENSE_STATEMENT}" | tr -d ' \t')
printf "PR description trimmed:\n%s" "${PR_DESCRIPTION}"
echo ""
echo ""
printf "Must contain trimmed:\n%s" "${LICENSE_STATEMENT}"
echo ""
echo ""
# Assert PR description contains license statement.
if printf "%s\n" "${PR_DESCRIPTION}" | grep -ixq "${LICENSE_STATEMENT}"; then
echo "Success: PR description contains license statement."
else
echo "Error: PR description does not contain the required license statement."
exit 1
fi

0 comments on commit 6bfcdc4

Please sign in to comment.