Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sanity check script and use it in pyinstaller GHA #5400

Merged
merged 6 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/workflows/validate_pyinstaller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches:
- develop

env:
CI_OVERRIDE: "1"

jobs:
build-for-linux:
name: build-pyinstaller-linux
Expand All @@ -15,15 +18,20 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20"
- name: Build PyInstaller
run: |
chmod +x ./installer/pyinstaller/build-linux.sh
CI_OVERRIDE=1 ./installer/pyinstaller/build-linux.sh aws-sam-cli-linux-x86_64.zip
./installer/pyinstaller/build-linux.sh aws-sam-cli-linux-x86_64.zip
- name: Basic tests for PyInstaller
run: |
unzip .build/output/aws-sam-cli-linux-x86_64.zip -d sam-installation
./sam-installation/install
sam-beta --version
./tests/sanity-check.sh
- uses: actions/upload-artifact@v3
with:
name: pyinstaller-linux-zip
Expand All @@ -41,15 +49,20 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: "3.7"
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20"
- name: Build PyInstaller
run: |
chmod +x ./installer/pyinstaller/build-mac.sh
CI_OVERRIDE=1 ./installer/pyinstaller/build-mac.sh aws-sam-cli-macos-x86_64.zip
./installer/pyinstaller/build-mac.sh aws-sam-cli-macos-x86_64.zip
- name: Basic tests for PyInstaller
run: |
unzip .build/output/aws-sam-cli-macos-x86_64.zip -d sam-installation
sudo ./sam-installation/install
sam-beta --version
./tests/sanity-check.sh
- uses: actions/upload-artifact@v3
with:
name: pyinstaller-macos-zip
Expand Down
45 changes: 45 additions & 0 deletions tests/sanity-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
set -xeo pipefail

export SAM_CLI_TELEMETRY="${SAM_CLI_TELEMETRY:-0}"

if [ "$CI_OVERRIDE" = "1" ]; then
sam_binary="sam-beta"
elif [ "$IS_NIGHTLY" = "1" ]; then
sam_binary="sam-nightly"
elif [ "$SAM_CLI_DEV" = "1" ]; then
sam_binary="samdev"
else
sam_binary="sam"
fi

if ! command -v "$sam_binary" &> /dev/null; then
echo "$sam_binary not found. Please check if it is in PATH"
exit 1
fi

echo "Using ${sam_binary} as SAM CLI binary name"

if [ "$sam_binary" = "sam" ]; then
SAMCLI_INSTALLED_VERSION=$($sam_binary --version | cut -d " " -f 4)

# Get latest SAM CLI version from GH main branch
SAMCLI_LATEST_VERSION=$(curl -L https://raw.githubusercontent.com/aws/aws-sam-cli/master/samcli/__init__.py | tail -n 1 | cut -d '"' -f 2)

# Check version
if [[ "$SAMCLI_INSTALLED_VERSION" != "$SAMCLI_LATEST_VERSION" ]]; then
echo "expected: $SAMCLI_LATEST_VERSION; got: $SAMCLI_INSTALLED_VERSION"
exit 1
fi

echo "Version check succeeded"
fi

echo "Starting testing sam binary"
rm -rf sam-app-testing
"$sam_binary" init --no-interactive -n sam-app-testing --dependency-manager mod --runtime go1.x --app-template hello-world --package-type Zip --architecture x86_64
cd sam-app-testing
GOFLAGS="-buildvcs=false" "$sam_binary" build
"$sam_binary" validate

echo "sam init, sam build, and sam validate commands Succeeded"