diff --git a/appveyor-linux-binary.yml b/appveyor-linux-binary.yml new file mode 100644 index 0000000000..187b3e4740 --- /dev/null +++ b/appveyor-linux-binary.yml @@ -0,0 +1,297 @@ +version: 1.0.{build} +image: + - Ubuntu2004 + +configuration: + - BuildIntegTesting + - LocalZipTerraformBuildIntegTesting + - LocalZipTerraformBuildInContainerIntegTesting + - S3ZipTerraformBuildIntegTesting + - S3ZipTerraformBuildInContainerIntegTesting + - OtherTerraformBuildIntegTesting + - DeployIntegTesting + - PackageIntegTesting + - DeleteIntegTesting + - SyncIntegTesting + - LocalIntegTesting + - EndToEndTesting + # other Integration testing, Dev, regression and smoke testing + - OtherTesting + +environment: + PYTHON_HOME: "$HOME/venv3.11/bin" + PYTHON_VERSION: '3.11' + AWS_DEFAULT_REGION: us-east-1 + NODE_VERSION: "14.17.6" + AWS_S3: 'AWS_S3_TESTING' + AWS_ECR: 'AWS_ECR_TESTING' + CARGO_LAMBDA_VERSION: "v0.17.1" + PYTHON_ARCH: '64' + NOSE_PARAMETERIZED_NO_WARN: 1 + APPVEYOR_CONSOLE_DISABLE_PTY: false + APPVEYOR_DETAILED_SHELL_LOGGING: true + + +install: + # AppVeyor's apt-get cache might be outdated, and the package could potentially be 404. + - sh: "sudo apt-get update --allow-releaseinfo-change" + + - sh: "gvm use go1.19" + - sh: "echo $PATH" + - sh: "ls /usr/" + # install latest maven which is compatible with jdk17 + - sh: "sudo apt-get -y remove maven" + - sh: "wget https://dlcdn.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.zip -P /tmp" + - sh: "sudo unzip -d /opt/mvn /tmp/apache-maven-*.zip" + - sh: "PATH=/opt/mvn/apache-maven-3.8.8/bin:$PATH" + - sh: "JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64" + - sh: "PATH=$JAVA_HOME/bin:$PATH" + - sh: "javac -version" + - sh: "java -version" + - sh: "mvn --version" + + - sh: "source ${HOME}/venv${PYTHON_VERSION}/bin/activate" + - sh: "rvm use 2.7.2" + - sh: "docker info" + - sh: "docker version" + - sh: "nvm install ${NODE_VERSION}" + - sh: "npm install npm@7.24.2 -g" + - sh: "npm -v" + + # Install latest gradle + - sh: "sudo apt-get -y remove gradle" + - sh: "wget https://services.gradle.org/distributions/gradle-7.3.1-bin.zip -P /tmp" + - sh: "sudo unzip -d /opt/gradle /tmp/gradle-*.zip" + - sh: "PATH=/opt/gradle/gradle-7.3.1/bin:$PATH" + + # Install AWS CLI + - sh: "virtualenv aws_cli" + - sh: "./aws_cli/bin/python -m pip install awscli" + - sh: "PATH=$(echo $PWD'/aws_cli/bin'):$PATH" + + - sh: "PATH=$PATH:$HOME/venv3.7/bin:$HOME/venv3.8/bin:$HOME/venv3.9/bin:$HOME/venv3.10/bin" + + # Install pytest + - sh: "python3.9 -m venv $HOME/pytest" + - sh: "$HOME/pytest/bin/python3 -m pip install -r requirements/pre-dev.txt" + - sh: "$HOME/pytest/bin/python3 -m pip install -r requirements/dev.txt" + - sh: "$HOME/pytest/bin/python3 -m pip install -r requirements/base.txt" + - sh: "PATH=$HOME/pytest/bin:$PATH" + - sh: "pytest --version" + + # update ca-certificates which causes failures with newest golang library + - sh: "sudo apt-get install --reinstall ca-certificates" + + # get testing env vars + - sh: "sudo apt install -y jq" + + # install Terraform + - sh: "sudo apt update --allow-releaseinfo-change" + - sh: "TER_VER=`curl -s https://api.github.com/repos/hashicorp/terraform/releases/latest | grep tag_name | cut -d: -f2 | tr -d \\\"\\,\\v | awk '{$1=$1};1'`" + - sh: "wget https://releases.hashicorp.com/terraform/${TER_VER}/terraform_${TER_VER}_linux_amd64.zip -P /tmp" + - sh: "sudo unzip -d /opt/terraform /tmp/terraform_${TER_VER}_linux_amd64.zip" + - sh: "sudo mv /opt/terraform/terraform /usr/local/bin/" + - sh: "terraform -version" + + # install Rust + - sh: "curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL https://sh.rustup.rs | sh -s -- --default-toolchain none -y > /dev/null 2>&1" + - sh: "source $HOME/.cargo/env" + - sh: "rustup toolchain install stable --profile minimal --no-self-update" + - sh: "rustup default stable" + - sh: "rustup target add x86_64-unknown-linux-gnu --toolchain stable" + - sh: "rustup target add aarch64-unknown-linux-gnu --toolchain stable" + - sh: "pip install cargo-lambda==$CARGO_LAMBDA_VERSION" + - sh: "rustc -V" + - sh: "cargo -V" + - sh: "cargo lambda -V" + + - sh: "python3.9 -m venv .venv_env_vars" + - sh: ".venv_env_vars/bin/pip install boto3" + - sh: "test_env_var=$(.venv_env_vars/bin/python tests/get_testing_resources.py)" + - sh: ' + if [ $? -ne 0 ]; then + echo "get_testing_resources failed. Failed to acquire credentials or test resources."; + false; + fi + ' + + - sh: 'export CI_ACCESS_ROLE_AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID' + - sh: 'export CI_ACCESS_ROLE_AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY' + - sh: 'export CI_ACCESS_ROLE_AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN' + + - sh: 'export AWS_ACCESS_KEY_ID=$(echo "$test_env_var" | jq -j ".accessKeyID")' + - sh: 'export AWS_SECRET_ACCESS_KEY=$(echo "$test_env_var" | jq -j ".secretAccessKey")' + - sh: 'export AWS_SESSION_TOKEN=$(echo "$test_env_var" | jq -j ".sessionToken")' + - sh: 'export TASK_TOKEN=$(echo "$test_env_var" | jq -j ".taskToken")' + - sh: 'export AWS_S3_TESTING=$(echo "$test_env_var" | jq -j ".TestBucketName")' + - sh: 'export AWS_ECR_TESTING=$(echo "$test_env_var" | jq -j ".TestECRURI")' + - sh: 'export AWS_KMS_KEY=$(echo "$test_env_var" | jq -j ".TestKMSKeyArn")' + - sh: 'export AWS_SIGNING_PROFILE_NAME=$(echo "$test_env_var" | jq -j ".TestSigningProfileName")' + - sh: 'export AWS_SIGNING_PROFILE_VERSION_ARN=$(echo "$test_env_var" | jq -j ".TestSigningProfileARN")' + + # required for RIE with arm64 in linux + - sh: " + if [[ -n $BY_CANARY ]] && [[ -n $DOCKER_USER ]] && [[ -n $DOCKER_PASS ]]; + then echo Logging in Docker Hub; echo $DOCKER_PASS | docker login --username $DOCKER_USER --password-stdin registry-1.docker.io; + fi" + - sh: " + if [[ -n $BY_CANARY ]] && [[ -n $DOCKER_USER ]] && [[ -n $DOCKER_PASS ]]; + then echo Logging in Docker Hub; echo $DOCKER_PASS | docker login --username $DOCKER_USER --password-stdin; + fi" + - sh: "docker run --rm --privileged multiarch/qemu-user-static --reset -p yes" + + + # Runs only in Linux, logging Public ECR when running canary and cred is available + - sh: " + if [[ -n $BY_CANARY ]]; + then echo Logging in Public ECR; aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws; + fi" + + +build_script: + - curl -L https://github.com/aws/aws-sam-cli/releases/download/sam-cli-nightly/aws-sam-cli-linux-x86_64.zip -o aws-sam-cli-linux-x86_64.zip + - unzip aws-sam-cli-linux-x86_64.zip -d sam-installation + - sudo ./sam-installation/install + # rename `sam-nightly` binary to `sam` + - sudo mv /usr/local/bin/sam-nightly /usr/local/bin/sam + - sam --version + +# Final clean up no matter success or failure +on_finish: + # Upload test reports as artifacts + - sh: find "$APPVEYOR_BUILD_FOLDER" -type f -name 'TEST_REPORT-*.json' -print0 | xargs -0 -I '{}' appveyor PushArtifact '{}' + - sh: > + AWS_ACCESS_KEY_ID=$TEST_REPORT_S3_BUCKET_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY=$TEST_REPORT_S3_BUCKET_SECRET_ACCESS_KEY + AWS_SESSION_TOKEN=$TEST_REPORT_S3_BUCKET_SESSION_TOKEN + aws s3 cp "$APPVEYOR_BUILD_FOLDER" "s3://$TEST_REPORT_S3_BUCKET_NAME/appveyor/$APPVEYOR_PROJECT_SLUG/$APPVEYOR_BUILD_ID/$APPVEYOR_JOB_ID/" --recursive --exclude "*" --include "TEST_REPORT-*.json" --region us-west-2 + + # notify task success + - sh: 'export AWS_ACCESS_KEY_ID=$CI_ACCESS_ROLE_AWS_ACCESS_KEY_ID' + - sh: 'export AWS_SECRET_ACCESS_KEY=$CI_ACCESS_ROLE_AWS_SECRET_ACCESS_KEY' + - sh: 'export AWS_SESSION_TOKEN=$CI_ACCESS_ROLE_AWS_SESSION_TOKEN' + + - sh: 'aws stepfunctions send-task-success --task-token "$TASK_TOKEN" --task-output "{}" --region us-west-2' + +for: + # Integ testing build + - + matrix: + only: + - configuration: BuildIntegTesting + + test_script: + - sh: "pytest -vv tests/integration/buildcmd --ignore=tests/integration/buildcmd/test_build_terraform_applications.py --ignore=tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json" + + # Set JAVA_HOME to java11 + - sh: "JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64" + - sh: "pytest -vv tests/integration/buildcmd/test_build_cmd.py -k test_building_java11_in_process --json-report --json-report-file=TEST_REPORT-integration-buildcmd-java11.json" + + # Local ZIP Terraform Build integ testing + - + matrix: + only: + - configuration: LocalZipTerraformBuildIntegTesting + + test_script: + - sh: "pytest -vv -n 4 tests/integration/buildcmd/test_build_terraform_applications.py::TestBuildTerraformApplicationsWithZipBasedLambdaFunctionAndLocalBackend_0 --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json" + + # Local ZIP Terraform Build In Container integ testing + - + matrix: + only: + - configuration: LocalZipTerraformBuildInContainerIntegTesting + + test_script: + - sh: "pytest -vv -n 4 tests/integration/buildcmd/test_build_terraform_applications.py::TestBuildTerraformApplicationsWithZipBasedLambdaFunctionAndLocalBackend_1 --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json" + + # S3 ZIP Terraform Build integ testing + - + matrix: + only: + - configuration: S3ZipTerraformBuildIntegTesting + + test_script: + - sh: "pytest -vv -n 4 tests/integration/buildcmd/test_build_terraform_applications.py::TestBuildTerraformApplicationsWithZipBasedLambdaFunctionAndS3Backend_0 --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json" + + # S3 ZIP Terraform Build In Container integ testing + - + matrix: + only: + - configuration: S3ZipTerraformBuildInContainerIntegTesting + + test_script: + - sh: "pytest -vv -n 4 tests/integration/buildcmd/test_build_terraform_applications.py::TestBuildTerraformApplicationsWithZipBasedLambdaFunctionAndS3Backend_1 --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json" + + # Other Terraform Build In Container integ testing + - + matrix: + only: + - configuration: OtherTerraformBuildIntegTesting + + test_script: + - sh: "pytest -vv -n 4 tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json" + + # Integ testing deploy + - + matrix: + only: + - configuration: DeployIntegTesting + + test_script: + - sh: "pytest -vv tests/integration/deploy -n 4 --reruns 4 --dist=loadgroup --json-report --json-report-file=TEST_REPORT-integration-deploy.json" + + # Integ testing package + - + matrix: + only: + - configuration: PackageIntegTesting + + test_script: + - sh: "pytest -vv tests/integration/package -n 4 --reruns 4 --json-report --json-report-file=TEST_REPORT-integration-package.json" + + # Integ testing delete + - + matrix: + only: + - configuration: DeleteIntegTesting + + test_script: + - sh: "pytest -vv tests/integration/delete -n 4 --reruns 4 --json-report --json-report-file=TEST_REPORT-integration-delete.json" + + # Integ testing sync + - + matrix: + only: + - configuration: SyncIntegTesting + + test_script: + - sh: "pytest -vv tests/integration/sync -n 3 --reruns 3 --dist loadscope --json-report --json-report-file=TEST_REPORT-integration-sync.json" + + # Integ testing local + - + matrix: + only: + - configuration: LocalIntegTesting + + test_script: + - sh: "pytest -vv tests/integration/local --json-report --json-report-file=TEST_REPORT-integration-local.json" + + # End-to-end testing + - + matrix: + only: + - configuration: EndToEndTesting + + test_script: + - sh: "pytest -vv -n 4 --reruns 5 --dist loadscope tests/end_to_end --json-report --json-report-file=TEST_REPORT-end-to-end.json" + + # Other testing + - + matrix: + only: + - configuration: OtherTesting + + test_script: + - sh: "pytest -vv -n 4 --reruns 4 --dist loadgroup tests/integration --ignore=tests/integration/buildcmd --ignore=tests/integration/delete --ignore=tests/integration/deploy --ignore=tests/integration/package --ignore=tests/integration/sync --ignore=tests/integration/local --json-report --json-report-file=TEST_REPORT-integration-others.json" + - sh: "pytest -vv tests/regression --json-report --json-report-file=TEST_REPORT-regression.json" diff --git a/appveyor-windows-binary.yml b/appveyor-windows-binary.yml new file mode 100644 index 0000000000..4cd5221819 --- /dev/null +++ b/appveyor-windows-binary.yml @@ -0,0 +1,309 @@ +version: 1.0.{build} +image: Visual Studio 2022 +build: off + +clone_folder: C:\source + +configuration: + - BuildIntegTesting + - LocalZipTerraformBuildIntegTesting + - LocalZipTerraformBuildInContainerIntegTesting + - S3ZipTerraformBuildIntegTesting + - S3ZipTerraformBuildInContainerIntegTesting + - OtherTerraformBuildIntegTesting + - DeployIntegTesting + - PackageIntegTesting + - DeleteIntegTesting + - SyncIntegTesting + - LocalIntegTesting + - EndToEndTesting + # other Integration testing, Dev, regression and smoke testing + - OtherTesting + +environment: + AWS_DEFAULT_REGION: us-east-1 + CARGO_LAMBDA_VERSION: "v0.17.1" + + # Python uses $TMPDIR envvar to find root of tempdir + TMPDIR: "%TEMP%" + TMP: "%TEMP%" + + # MSI Installers only use Py3.8. It is sufficient to test with this version here. + PYTHON_HOME: "C:\\Python38-x64" + PYTHON_SCRIPTS: "C:\\Python38-x64\\Scripts" + PYTHON_EXE: "C:\\Python38-x64\\python.exe" + PYTHON_ARCH: "64" + HOME: 'C:\Users\appveyor' + HOMEDRIVE: "C:" + HOMEPATH: 'C:\Users\appveyor' + NOSE_PARAMETERIZED_NO_WARN: 1 + AWS_S3: "AWS_S3_TESTING" + AWS_ECR: "AWS_ECR_TESTING" + APPVEYOR_CONSOLE_DISABLE_PTY: true + + SAM_WINDOWS_BINARY_PATH: "C:\\Program Files\\Amazon\\AWSSAMCLI_NIGHTLY\\bin\\sam-nightly.cmd" + +init: + # Uncomment this for RDP + # - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + - ps: gcim Win32_Processor | % { "$($_.NumberOfLogicalProcessors) logical CPUs" } + - ps: gcim Win32_OperatingSystem | % { "$([int]($_.TotalVisibleMemorySize/1mb)) Gb" } + - git config --global core.autocrlf false + - ps: New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force + - ps: git config --system core.longpaths true + +cache: + - C:\ProgramData\chocolatey\bin -> appveyor.yml + - C:\ProgramData\chocolatey\lib -> appveyor.yml + +install: + # setup make + - "choco install make" + # setup Java, Maven and Gradle + - "choco install gradle -y --force" + - 'set JAVA_HOME=C:\Program Files\Java\jdk17' + - 'set PATH=%JAVA_HOME%\bin;%PATH%' + - "javac -version" + - "java -version" + - "gradle -v" + - "mvn --version" + + # Make sure the temp directory exists for Python to use. + - ps: "mkdir -Force C:\\tmp" + - 'set PATH=%PYTHON_HOME%;C:\Ruby27-x64\bin;%PATH%;C:\Python37-x64;C:\Python39-x64;C:\Python310-x64' + - "echo %PYTHON_HOME%" + - "echo %PATH%" + - "python --version" + - "docker info" + - "docker version" + + # install Terraform CLI + - "choco install terraform" + - "terraform -version" + + # Upgrade setuptools, wheel and virtualenv + - "python -m pip install --upgrade setuptools wheel virtualenv" + # Install pip for the python versions which is used by the tests + - "C:\\Python37-x64\\python.exe -m pip install --upgrade pip" + - "C:\\Python39-x64\\python.exe -m pip install --upgrade pip" + - "C:\\Python310-x64\\python.exe -m pip install --upgrade pip" + + # Install AWS CLI Globally via pip3 + - "pip install awscli" + + # Switch to Docker Linux containers + - ps: Switch-DockerLinux + + # Check for git executable + - "git --version" + + # Get testing env vars + - ps: " + If (Test-Path env:BY_CANARY){ + python -m virtualenv venv_env_vars; + ./venv_env_vars/Scripts/pip install boto3; + $test_env_var = ./venv_env_vars/Scripts/python tests/get_testing_resources.py; + $test_env_var_json = ConvertFrom-Json $test_env_var; + + $env:CI_ACCESS_ROLE_AWS_ACCESS_KEY_ID = $env:AWS_ACCESS_KEY_ID; + $env:CI_ACCESS_ROLE_AWS_SECRET_ACCESS_KEY = $env:AWS_SECRET_ACCESS_KEY; + $env:CI_ACCESS_ROLE_AWS_SESSION_TOKEN = $env:AWS_SESSION_TOKEN; + + $env:AWS_ACCESS_KEY_ID = $test_env_var_json.accessKeyID; + $env:AWS_SECRET_ACCESS_KEY = $test_env_var_json.secretAccessKey; + $env:AWS_SESSION_TOKEN = $test_env_var_json.sessionToken; + $env:TASK_TOKEN = $test_env_var_json.taskToken; + $env:AWS_S3_TESTING = $test_env_var_json.TestBucketName; + $env:AWS_ECR_TESTING = $test_env_var_json.TestECRURI; + $env:AWS_KMS_KEY = $test_env_var_json.TestKMSKeyArn; + $env:AWS_SIGNING_PROFILE_NAME = $test_env_var_json.TestSigningProfileName; + $env:AWS_SIGNING_PROFILE_VERSION_ARN = $test_env_var_json.TestSigningProfileARN; + }" + + + # Create new virtual environment with chosen python version and activate it + - "python -m virtualenv venv" + - "venv\\Scripts\\activate" + - "python --version" + + # Install testing pre-reqs without installing sam-cli from source + - pip install -r requirements/pre-dev.txt" + - pip install -r requirements/dev.txt" + - pip install -r requirements/base.txt + - pytest --version + + # Install aws cli + - "pip install awscli" + + # Install aws-sam-cli MSI binary + - ps: " + Invoke-WebRequest -Uri https://github.com/aws/aws-sam-cli/releases/download/sam-cli-nightly/AWS_SAM_CLI_64_PY3.msi -OutFile aws-sam-cli-installer.msi; + Start-Process 'C:\\Windows\\System32\\msiexec.exe' -ArgumentList '/i aws-sam-cli-installer.msi /qn /norestart' -wait -PassThru; + " + - 'set PATH=C:\Program Files\Amazon\AWSSAMCLI_NIGHTLY\bin\;%PATH%' + - 'sam-nightly --version' + + # Echo final Path + - "echo %PATH%" + + # use amazon-ecr-credential-helper + - choco install amazon-ecr-credential-helper + - ps: " + $docker_config = Get-Content $env:HOME/.docker/config.json -raw | ConvertFrom-Json; + $docker_config.credsStore = 'ecr-login'; + $docker_config | ConvertTo-Json | set-content $env:HOME/.docker/config.json; + " + - ps: "get-content $env:HOME/.docker/config.json" + + # claim some disk space before starting the tests + - "docker system prune -a -f" + + +# Final clean up no matter success or failure +on_finish: + # Upload test reports as artifacts + - ps: Get-ChildItem .\TEST_REPORT-*.json | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } + - ps: ' + If (Test-Path env:BY_CANARY){ + $env:AWS_ACCESS_KEY_ID = $env:TEST_REPORT_S3_BUCKET_ACCESS_KEY_ID; + $env:AWS_SECRET_ACCESS_KEY = $env:TEST_REPORT_S3_BUCKET_SECRET_ACCESS_KEY; + $env:AWS_SESSION_TOKEN = $env:TEST_REPORT_S3_BUCKET_SESSION_TOKEN; + aws s3 cp ".\" "s3://$env:TEST_REPORT_S3_BUCKET_NAME/appveyor/$env:APPVEYOR_PROJECT_SLUG/$env:APPVEYOR_BUILD_ID/$env:APPVEYOR_JOB_ID/" --recursive --exclude "*" --include "TEST_REPORT-*.json" --region us-west-2 + }' + + # notify success + - ps: " + If (Test-Path env:BY_CANARY){ + $env:AWS_ACCESS_KEY_ID = $env:CI_ACCESS_ROLE_AWS_ACCESS_KEY_ID; + $env:AWS_SECRET_ACCESS_KEY = $env:CI_ACCESS_ROLE_AWS_SECRET_ACCESS_KEY; + $env:AWS_SESSION_TOKEN = $env:CI_ACCESS_ROLE_AWS_SESSION_TOKEN; + aws stepfunctions send-task-success --task-token \"$env:TASK_TOKEN\" --task-output \"{}\" --region us-west-2; + }" + + +for: + #Integ testing build, regression + - matrix: + only: + - configuration: BuildIntegTesting + + build_script: + # install Rust in build_script to not override the default "install" actions + - appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe + - rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain stable + - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin + - set RUST_BACKTRACE=1 + - rustup toolchain install stable --profile minimal --no-self-update + - rustup default stable + - rustup target add x86_64-unknown-linux-gnu --toolchain stable + - rustup target add aarch64-unknown-linux-gnu --toolchain stable + - ps: "choco install zig" + - ps: Invoke-WebRequest -Uri https://github.com/cargo-lambda/cargo-lambda/releases/download/$env:CARGO_LAMBDA_VERSION/cargo-lambda-$env:CARGO_LAMBDA_VERSION.windows-x64.zip -OutFile C:\Users\appveyor\cargo-lambda.zip + - ps: Expand-Archive -DestinationPath C:\Users\appveyor\.cargo\bin C:\Users\appveyor\cargo-lambda.zip + - rustc -V + - cargo -V + - cargo lambda -V + + test_script: + - ps: "pytest -vv tests/integration/buildcmd --ignore tests/integration/buildcmd/test_build_terraform_applications.py --ignore=tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json" + + # Local ZIP Terraform Build integ testing + - matrix: + only: + - configuration: LocalZipTerraformBuildIntegTesting + + test_script: + - ps: "pytest -vv -n 4 tests/integration/buildcmd/test_build_terraform_applications.py::TestBuildTerraformApplicationsWithZipBasedLambdaFunctionAndLocalBackend_0 --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json" + + # Local ZIP Terraform Build In Container integ testing + - matrix: + only: + - configuration: LocalZipTerraformBuildInContainerIntegTesting + + test_script: + - ps: "pytest -vv tests/integration/buildcmd/test_build_terraform_applications.py::TestBuildTerraformApplicationsWithZipBasedLambdaFunctionAndLocalBackend_1 --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json" + + # S3 ZIP Terraform Build integ testing + - matrix: + only: + - configuration: S3ZipTerraformBuildIntegTesting + + test_script: + - ps: "pytest -vv -n 4 tests/integration/buildcmd/test_build_terraform_applications.py::TestBuildTerraformApplicationsWithZipBasedLambdaFunctionAndS3Backend_0 --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json" + + # S3 ZIP Terraform Build In Container integ testing + - matrix: + only: + - configuration: S3ZipTerraformBuildInContainerIntegTesting + + test_script: + - ps: "pytest -vv tests/integration/buildcmd/test_build_terraform_applications.py::TestBuildTerraformApplicationsWithZipBasedLambdaFunctionAndS3Backend_1 --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json" + + # Other Terraform Build integ testing + - matrix: + only: + - configuration: OtherTerraformBuildIntegTesting + + test_script: + - ps: "pytest -vv -n 4 tests/integration/buildcmd/test_build_terraform_applications_other_cases.py --json-report --json-report-file=TEST_REPORT-integration-buildcmd.json" + + #Integ testing deploy + - matrix: + only: + - configuration: DeployIntegTesting + + test_script: + - ps: "pytest -vv tests/integration/deploy -n 4 --reruns 4 --dist=loadgroup --json-report --json-report-file=TEST_REPORT-integration-deploy.json" + + # Integ testing package + - matrix: + only: + - configuration: PackageIntegTesting + + test_script: + - ps: "pytest -vv tests/integration/package -n 4 --reruns 4 --json-report --json-report-file=TEST_REPORT-integration-package.json" + + # Integ testing delete + - matrix: + only: + - configuration: DeleteIntegTesting + + test_script: + - ps: "pytest -vv tests/integration/delete -n 4 --reruns 4 --json-report --json-report-file=TEST_REPORT-integration-delete.json" + + # Integ testing sync + - matrix: + only: + - configuration: SyncIntegTesting + + test_script: + - ps: "pytest -vv tests/integration/sync -n 3 --reruns 3 --dist loadscope --json-report --json-report-file=TEST_REPORT-integration-sync.json" + + #Integ testing local + - matrix: + only: + - configuration: LocalIntegTesting + + test_script: + - ps: "pytest -vv tests/integration/local --json-report --json-report-file=TEST_REPORT-integration-local.json" + + # End-to-end testing + - matrix: + only: + - configuration: EndToEndTesting + + test_script: + - ps: "pytest -vv -n 4 --reruns 5 --dist loadscope tests/end_to_end --json-report --json-report-file=TEST_REPORT-end-to-end.json" + + #Other testing + - matrix: + only: + - configuration: OtherTesting + + test_script: + - ps: "pytest -vv -n 4 --reruns 4 --dist loadgroup tests/integration --ignore=tests/integration/buildcmd --ignore=tests/integration/delete --ignore=tests/integration/deploy --ignore=tests/integration/package --ignore=tests/integration/sync --ignore=tests/integration/local --json-report --json-report-file=TEST_REPORT-integration-others.json" + - ps: "pytest -vv tests/regression --json-report --json-report-file=TEST_REPORT-regression.json" +# Uncomment for RDP +# on_finish: +# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + diff --git a/tests/integration/init/test_init_command.py b/tests/integration/init/test_init_command.py index b852f5493c..303c39bc44 100644 --- a/tests/integration/init/test_init_command.py +++ b/tests/integration/init/test_init_command.py @@ -743,13 +743,8 @@ def test_init_command_wrong_packagetype(self): self.assertEqual(process.returncode, 2) errmsg = """ -Usage: {0} init [OPTIONS] -Try '{0} init -h' for help. - Error: Invalid value for '-p' / '--package-type': 'WrongPT' is not one of 'Zip', 'Image'. - """.format( - get_sam_command() - ) + """ self.assertIn(errmsg.strip(), "\n".join(stderr.strip().splitlines())) diff --git a/tests/integration/telemetry/test_experimental_metric.py b/tests/integration/telemetry/test_experimental_metric.py index 702ceb4a5f..1c8ca5b223 100644 --- a/tests/integration/telemetry/test_experimental_metric.py +++ b/tests/integration/telemetry/test_experimental_metric.py @@ -7,6 +7,7 @@ from .integ_base import IntegBase, TelemetryServer from samcli import __version__ as SAM_CLI_VERSION +from ...testing_utils import strip_nightly_installer_suffix class TestExperimentalMetric(IntegBase): @@ -162,6 +163,7 @@ def test_must_send_cdk_project_type_metrics(self): for req in all_requests: if "commandRun" in req["data"]["metrics"][0]: request = req # We're only testing the commandRun metric + strip_nightly_installer_suffix(request, "commandRun") self.assertIn("Content-Type", request["headers"]) self.assertEqual(request["headers"]["Content-Type"], "application/json") @@ -216,6 +218,7 @@ def test_must_send_not_experimental_metrics_if_not_experimental(self): # commandRun metric will be first or second, so we sort for consistency. all_requests.sort(key=lambda x: list(x["data"]["metrics"][0].keys())[0]) request = all_requests[0] # "commandRun" comes before "events" + strip_nightly_installer_suffix(request, "commandRun") self.assertIn("Content-Type", request["headers"]) self.assertEqual(request["headers"]["Content-Type"], "application/json") diff --git a/tests/integration/telemetry/test_installed_metric.py b/tests/integration/telemetry/test_installed_metric.py index 725a2d0ff5..0b0d2d550e 100644 --- a/tests/integration/telemetry/test_installed_metric.py +++ b/tests/integration/telemetry/test_installed_metric.py @@ -3,6 +3,7 @@ from unittest.mock import ANY from .integ_base import IntegBase, TelemetryServer, EXPECTED_TELEMETRY_PROMPT from samcli import __version__ as SAM_CLI_VERSION +from ...testing_utils import strip_nightly_installer_suffix class TestSendInstalledMetric(IntegBase): @@ -32,6 +33,7 @@ def test_send_installed_metric_on_first_run(self): requests = filter_installed_metric_requests(all_requests) self.assertEqual(1, len(requests), "There should be only one 'installed' metric") request = requests[0] + strip_nightly_installer_suffix(request, "installed") self.assertIn("Content-Type", request["headers"]) self.assertEqual(request["headers"]["Content-Type"], "application/json") diff --git a/tests/regression/package/regression_package_base.py b/tests/regression/package/regression_package_base.py index eece11503e..744ac55717 100644 --- a/tests/regression/package/regression_package_base.py +++ b/tests/regression/package/regression_package_base.py @@ -10,6 +10,7 @@ import boto3 from samcli.yamlhelper import yaml_parse +from tests.testing_utils import get_sam_command S3_SLEEP = 3 TIMEOUT = 300 @@ -40,8 +41,8 @@ def tearDownClass(cls): def base_command(self, base): command = [base] - if os.getenv("SAM_CLI_DEV") and base == "sam": - command = ["samdev"] + if base == "sam": + command = [get_sam_command()] elif base == "aws": command = [base, "cloudformation"] diff --git a/tests/testing_utils.py b/tests/testing_utils.py index a52898f90b..aa281091cf 100644 --- a/tests/testing_utils.py +++ b/tests/testing_utils.py @@ -11,6 +11,8 @@ from subprocess import Popen, PIPE, TimeoutExpired from queue import Queue +from samcli import __version__ as SAM_CLI_VERSION + import shutil from uuid import uuid4 @@ -44,6 +46,9 @@ def get_sam_command(): + windows_bin_path = os.getenv("SAM_WINDOWS_BINARY_PATH") + if windows_bin_path: + return windows_bin_path return "samdev" if os.getenv("SAM_CLI_DEV") else "sam" @@ -242,6 +247,19 @@ def _get_current_account_id(): return account_id +def strip_nightly_installer_suffix(request: dict, metric_type: str): + """ + If it's a nightly release version, it will have a suffix. + We can strip it for the purpose of testing telemetry. + """ + metrics = request.get("data", {}).get("metrics", []) + if not metrics: + return + version = metrics[0].get(metric_type, {}).get("samcliVersion", "") + if version: + request["data"]["metrics"][0][metric_type]["samcliVersion"] = version[: len(SAM_CLI_VERSION)] + + class UpdatableSARTemplate: """ This class is used to replace the `${AWS::AccountId}` in the testing templates with the account id for the testing