mirror of
https://github.com/GAM-team/GAM.git
synced 2025-05-11 19:57:21 +00:00
* pre-commit run trailing-whitespace -a * pre-commit run end-of-file-fixer -a * pre-commit run double-quote-string-fixer -a * pre-commit run requirements-txt-fixer -a * add pyupgrade hook * remove pre-commit default_language_version 3.7 (since no upwards incompatible hooks)
419 lines
19 KiB
YAML
419 lines
19 KiB
YAML
name: Build and test GAM
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
schedule:
|
|
- cron: '37 22 * * *'
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
working-directory: src
|
|
|
|
env:
|
|
BUILD_PYTHON_VERSION: "3.10.2"
|
|
MIN_PYTHON_VERSION: "3.10.1"
|
|
BUILD_OPENSSL_VERSION: "3.0.1"
|
|
MIN_OPENSSL_VERSION: "1.1.1l"
|
|
PATCHELF_VERSION: "0.13"
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-18.04
|
|
jid: 1
|
|
goal: "build"
|
|
gamos: "linux"
|
|
platform: "x86_64"
|
|
- os: ubuntu-20.04
|
|
jid: 2
|
|
goal: "build"
|
|
gamos: "linux"
|
|
platform: "x86_64"
|
|
- os: macos-11.0
|
|
jid: 3
|
|
goal: "build"
|
|
gamos: "macos"
|
|
platform: "universal2"
|
|
- os: windows-2022
|
|
jid: 4
|
|
goal: "build"
|
|
gamos: "windows"
|
|
pyarch: "x64"
|
|
platform: "x86_64"
|
|
- os: windows-2022
|
|
jid: 5
|
|
goal: "build"
|
|
gamos: "windows"
|
|
platform: "x86"
|
|
pyarch: "x86"
|
|
- os: ubuntu-20.04
|
|
goal: "test"
|
|
python: "3.7"
|
|
jid: 6
|
|
gamos: "linux"
|
|
platform: "x86_64"
|
|
- os: ubuntu-20.04
|
|
goal: "test"
|
|
python: "3.8"
|
|
jid: 7
|
|
gamos: "linux"
|
|
platform: "x86_64"
|
|
- os: ubuntu-20.04
|
|
goal: test
|
|
python: "3.9"
|
|
jid: 8
|
|
gamos: linux
|
|
platform: x86_64
|
|
- os: [self-hosted, linux, arm64]
|
|
jid: 9
|
|
goal: "self-build"
|
|
platform: "aarch64"
|
|
gamos: linux
|
|
- os: [self-hosted, linux, arm]
|
|
jid: 10
|
|
goal: "self-build"
|
|
platform: "armv7l"
|
|
gamos: linux
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@master
|
|
with:
|
|
persist-credentials: false
|
|
fetch-depth: 0
|
|
|
|
- name: Cache multiple paths
|
|
uses: actions/cache@v2
|
|
if: matrix.goal != 'test'
|
|
with:
|
|
path: |
|
|
~/python
|
|
~/ssl
|
|
key: ${{ matrix.os }}-${{ matrix.jid }}-20220115
|
|
|
|
- name: Set env variables
|
|
env:
|
|
GAMOS: ${{ matrix.gamos }}
|
|
GOAL: ${{ matrix.goal }}
|
|
JID: ${{ matrix.jid }}
|
|
PLATFORM: ${{ matrix.platform }}
|
|
run: |
|
|
echo "GAMOS=${GAMOS}" >> $GITHUB_ENV
|
|
echo "GOAL=${GOAL}" >> $GITHUB_ENV
|
|
echo "JID=${JID}" >> $GITHUB_ENV
|
|
echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV
|
|
uname -a
|
|
|
|
- name: Use pre-compiled Python for testing
|
|
if: matrix.python != ''
|
|
uses: actions/setup-python@v2
|
|
with:
|
|
python-version: ${{ matrix.python }}
|
|
architecture: ${{ matrix.pyarch }}
|
|
|
|
- name: Install Python on Windows
|
|
if: matrix.os == 'windows-2022'
|
|
run: |
|
|
$Env:BUILD_PYTHON_VERSION = "3.10.1"
|
|
if ( ${Env:PLATFORM} -eq "x86_64" )
|
|
{
|
|
Set-Variable -name py_arch -value "-amd64"
|
|
}
|
|
else
|
|
{
|
|
Set-Variable -name py_arch -value ""
|
|
}
|
|
Write-Output "py_arch: $py_arch"
|
|
Set-Variable -name python_file -value "python-${Env:BUILD_PYTHON_VERSION}${py_arch}.exe"
|
|
Write-Output "python_file: $python_file"
|
|
Set-Variable -name python_url -value "https://www.python.org/ftp/python/${Env:BUILD_PYTHON_VERSION}/${python_file}"
|
|
Write-Output "python_url: $python_url"
|
|
Invoke-WebRequest -Uri $python_url -OutFile $python_file
|
|
Start-Process -wait -FilePath $python_file -ArgumentList "/quiet","InstallAllUsers=0","TargetDir=c:\\python","AssociateFiles=1","PrependPath=1"
|
|
shell: pwsh
|
|
|
|
- name: Install packages for test
|
|
if: matrix.goal == 'test'
|
|
run: |
|
|
echo "RUNNING: apt update..."
|
|
sudo apt-get -qq --yes update > /dev/null
|
|
sudo apt-get -qq --yes install swig libpcsclite-dev
|
|
|
|
- name: Set env variables for pre-compiled Python
|
|
if: matrix.goal == 'test'
|
|
run: |
|
|
export python=$(which python3)
|
|
export pip=$(which pip3)
|
|
export gam="${python} -m gam"
|
|
export gampath="$(readlink -e .)"
|
|
echo -e "python: $python\npip: $pip\ngam: $gam\ngampath: $gampath"
|
|
echo "python=${python}" >> $GITHUB_ENV
|
|
echo "pip=${pip}" >> $GITHUB_ENV
|
|
echo "gam=${gam}" >> $GITHUB_ENV
|
|
echo "gampath=${gampath}" >> $GITHUB_ENV
|
|
$pip install --upgrade pip
|
|
"${python}" -V
|
|
"${pip}" -V
|
|
|
|
- name: Build and install Python and OpenSSL
|
|
if: (matrix.goal == 'build' || matrix.goal == 'self-build') && steps.cache-primes.outputs.cache-hit != 'true'
|
|
run: |
|
|
set +e
|
|
source ../.github/actions/${GAMOS}-before-install.sh
|
|
echo "python=$python" >> $GITHUB_ENV
|
|
echo "pip=$pip" >> $GITHUB_ENV
|
|
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV
|
|
if [ $GAMOS == "macos" ]; then
|
|
brew install openssl@1.1 rust
|
|
export LDFLAGS="-L$(brew --prefix openssl@1.1)/lib"
|
|
export pipoptions='--no-binary :all:'
|
|
echo "PATH=$PATH" >> $GITHUB_ENV # keep gnutools for MacOS
|
|
export MACOSX_DEPLOYMENT_TARGET="10.9"
|
|
export CFLAGS="-arch arm64 -arch x86_64 -I$(brew --prefix openssl@1.1)/include"
|
|
echo "pipoptions=${pipoptions}" >> $GITHUB_ENV
|
|
echo "MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}" >> $GITHUB_ENV
|
|
echo "CFLAGS=${CFLAGS}" >> $GITHUB_ENV
|
|
echo "LDFLAGS=${LDFLAGS}" >> $GITHUB_ENV
|
|
fi
|
|
echo -e "Python: $python\nPip: $pip\nLD_LIB...: $LD_LIBRARY_PATH"
|
|
$pip install --upgrade pip $pipoptions
|
|
$pip install --upgrade wheel $pipoptions
|
|
|
|
- name: Set Windows Powershell env variables
|
|
if: matrix.goal != 'test' && matrix.os == 'windows-2022' && matrix.platform == 'x86_64'
|
|
shell: powershell
|
|
run: |
|
|
choco install nasm --no-progress
|
|
$env:PATH="$ENV:PATH;c:\Program Files\NASM\"
|
|
cmd /c 'call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && set MAKE=nmake && set > %temp%\vcvars.txt'
|
|
Get-Content "$env:temp\vcvars.txt" | Foreach-Object {
|
|
if ($_ -match "^(.*?)=(.*)$") {
|
|
if ($matches[1] -eq "PATH" -or $matches[1] -eq "PLATFORM") {
|
|
continue
|
|
}
|
|
Set-Content "env:\$($matches[1])" $matches[2]
|
|
Add-Content -Path $env:GITHUB_ENV -Value "$($matches[1])=$($matches[2])"
|
|
}
|
|
}
|
|
|
|
- name: Install PyInstaller
|
|
if: matrix.goal != 'test'
|
|
run: |
|
|
set +e
|
|
git clone https://github.com/pyinstaller/pyinstaller.git
|
|
cd pyinstaller
|
|
# use latest pyinstaller tag version
|
|
git fetch --tags
|
|
git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
|
|
# remove pre-compiled bootloaders so we fail if bootloader compile fails
|
|
rm -rf PyInstaller/bootloader/*-*/*
|
|
cd bootloader
|
|
export DefaultWindowsSDKVersion="10.0.20348.0"
|
|
if [ "${PLATFORM}" == "x86" ]; then
|
|
TARGETARCH="32bit"
|
|
else
|
|
TARGETARCH="64bit"
|
|
fi
|
|
if [ $GAMOS == "macos" ]; then
|
|
UNIVERsAL="--universal2"
|
|
fi
|
|
$python ./waf all --target-arch=$TARGETARCH $UNIVERSAL
|
|
cat build/config.log
|
|
cd ..
|
|
$pip install . $pipoptions
|
|
|
|
- name: Install pip requirements
|
|
run: |
|
|
set +e
|
|
$pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 $pip install -U --force-reinstall $pipoptions
|
|
$pip install --upgrade -r requirements.txt $pipoptions
|
|
# yubikey-manager holds cryptography to old version, force upgrade
|
|
# $pip install --upgrade --no-deps cryptography $pipoptions
|
|
|
|
- name: Build GAM with PyInstaller
|
|
if: matrix.goal != 'test'
|
|
run: |
|
|
set +e
|
|
source ../.github/actions/${GAMOS}-install.sh
|
|
ls -alRF $gampath
|
|
echo "gampath=$gampath" >> $GITHUB_ENV
|
|
echo "gam=$gam" >> $GITHUB_ENV
|
|
echo -e "GAM: ${gam}\nGAMPATH: ${gampath}\nGAMVERSION: ${GAMVERSION}"
|
|
|
|
- name: Basic Tests all jobs
|
|
run: |
|
|
echo -e "python: $python\npip: $pip\ngam: $gam\ngampath: $gampath\n"
|
|
$python -m unittest discover --start-directory ./ --pattern "*_test.py" --buffer
|
|
touch "${gampath}/nobrowser.txt"
|
|
$gam version extended
|
|
export GAMVERSION=$($gam version simple)
|
|
echo "GAM Version ${GAMVERSION}"
|
|
echo "GAMVERSION=${GAMVERSION}" >> $GITHUB_ENV
|
|
|
|
- name: Basic Tests build jobs only
|
|
if: matrix.goal != 'test'
|
|
run: |
|
|
$pip install packaging
|
|
export vline=$($gam version | grep "Python ")
|
|
export python_line=($vline)
|
|
export this_python=${python_line[1]}
|
|
$python tools/a_atleast_b.py "${this_python}" "${MIN_PYTHON_VERSION}"
|
|
export vline=$($gam version extended | grep "OpenSSL ")
|
|
export openssl_line=($vline)
|
|
export this_openssl="${openssl_line[1]}"
|
|
$python tools/a_atleast_b.py "${this_openssl}" "${MIN_OPENSSL_VERSION}"
|
|
|
|
|
|
- name: Live API tests push only
|
|
if: github.event_name == 'push' || github.event_name == 'schedule'
|
|
env:
|
|
PASSCODE: ${{ secrets.PASSCODE }}
|
|
run: |
|
|
source ../.github/actions/decrypt.sh ../.github/actions/creds.tar.gpg creds.tar
|
|
export OAUTHFILE="oauth2.txt-gam-gha-${JID}"
|
|
echo "OAUTHFILE=${OAUTHFILE}" >> $GITHUB_ENV
|
|
export gam_user="gam-gha-${JID}@pdl.jaylee.us"
|
|
echo "gam_user=${gam_user}" >> $GITHUB_ENV
|
|
$gam oauth info
|
|
$gam info domain
|
|
$gam oauth refresh
|
|
$gam info user
|
|
#$gam info user $gam_user grouptree
|
|
export tstamp=$(date +%s%3N)
|
|
export newbase=gha-test-$JID-$tstamp
|
|
export newuser=$newbase@pdl.jaylee.us
|
|
export newgroup=$newbase-group@pdl.jaylee.us
|
|
export newalias=$newbase-alias@pdl.jaylee.us
|
|
export newbuilding=$newbase-building
|
|
export newresource=$newbase-resource
|
|
export GAM_THREADS=5
|
|
echo email > sample.csv;
|
|
for i in {01..10}; do
|
|
echo "${newbase}-bulkuser-$i" >> sample.csv;
|
|
done
|
|
$gam create user $newuser firstname GHA lastname $JID password random recoveryphone 12125121110 recoveryemail jay0lee@gmail.com gha.jid $JID languages en+,en-GB-
|
|
$gam user $gam_user sendemail recipient $newuser subject "test message $newbase" message "GHA test message"
|
|
$gam user $gam_user sendemail recipient exchange@pdl.jaylee.us subject "test ${tstamp}" message "test message"
|
|
$gam create group $newgroup name "GHA $JID group" description "This is a description" isarchived true
|
|
$gam update cigroup $newgroup memberrestriction 'member.type == 1 || member.customer_id == groupCustomerId()'
|
|
$gam info cigroup $newgroup
|
|
$gam user $newuser add license workspaceenterpriseplus
|
|
$gam update group $newgroup add owner $gam_user
|
|
$gam update group $newgroup add member $newuser
|
|
$gam csv sample.csv gam create user ~~email~~ firstname "GHA Bulk" lastname ~~email~~ gha.jid $JID
|
|
$gam csv sample.csv gam update user ~~email~~ recoveryphone 12125121110 recoveryemail jay0lee@gmail.com password random
|
|
$gam csv sample.csv gam update user ~~email~~ recoveryphone "" recoveryemail ""
|
|
$gam csv sample.csv gam user ~email add license workspaceenterpriseplus
|
|
$gam csv sample.csv gam user $gam_user sendemail recipient ~~email~~@pdl.jaylee.us subject "test message $newbase" message "GHA test message"
|
|
$gam csv sample.csv gam update group $newgroup add member ~email
|
|
$gam info group $newgroup
|
|
$gam info cigroup $newgroup membertree
|
|
$gam user $gam_user check serviceaccount
|
|
# confirm mailbox is provisoned before continuing
|
|
$gam user $newuser waitformailbox
|
|
$gam user $newuser imap on
|
|
$gam user $newuser show imap
|
|
$gam user $newuser show delegates
|
|
#$gam user $newuser add contactdelegate "${newbase}-bulkuser-01"
|
|
#$gam user $newuser print contactdelegates
|
|
export biohazard=$(echo -e '\xe2\x98\xa3')
|
|
$gam user $newuser label "$biohazard unicode biohazard $biohazard"
|
|
$gam user $newuser show labels
|
|
$gam user $newuser show labels > labels.txt
|
|
$gam user $gam_user importemail subject "GHA import $newbase" message "This is a test import" labels IMPORTANT,UNREAD,INBOX,STARRED
|
|
$gam user $gam_user insertemail subject "GHA insert $newbase" file gam.py labels INBOX,UNREAD # yep body is gam code
|
|
$gam user $gam_user sendemail subject "GHA send $gam_user $newbase" file gam.py recipient admin@pdl.jaylee.us
|
|
$gam user $gam_user draftemail subject "GHA draft $newbase" message "Draft message test"
|
|
$gam csvfile sample.csv:email waitformailbox
|
|
$gam user $newuser delegate to "${newbase}-bulkuser-01"
|
|
$gam users "$gam_user $newbase-bulkuser-01 $newbase-bulkuser-02 $newbase-bulkuser-03" delete messages query in:anywhere maxtodelete 99999 doit
|
|
$gam users "$newbase-bulkuser-04 $newbase-bulkuser-05 $newbase-bulkuser-06" trash messages query in:anywhere maxtotrash 99999 doit
|
|
$gam users "$newbase-bulkuser-07 $newbase-bulkuser-08 $newbase-bulkuser-09" modify messages query in:anywhere maxtomodify 99999 addlabel IMPORTANT addlabel STARRED doit
|
|
$gam user $newuser delete label --ALL_LABELS--
|
|
$gam create feature name Whiteboard-$newbase
|
|
$gam create feature name VC-$newbase
|
|
$gam create building "My Building - $newbase" id $newbuilding floors 1,2,3,4,5,6,7,8,9,10,11,12,14,15 description "No 13th floor here..."
|
|
$gam create resource $newresource "Resource Calendar $tstamp" capacity 25 features Whiteboard-$newbase,VC-$newbase building $newbuilding floor 15 type Room
|
|
$gam info resource $newresource
|
|
$gam user $newuser show filelist
|
|
$gam calendar $gam_user printacl | $gam csv - gam calendar $gam_user delete id ~id # clear ACLs
|
|
$gam calendar $gam_user update read domain
|
|
$gam calendar $gam_user update freebusy default
|
|
$gam calendar $gam_user add editor $newuser
|
|
$gam calendar $gam_user showacl
|
|
$gam calendar $gam_user printacl | $gam csv - gam calendar $gam_user delete id ~id
|
|
$gam calendar $gam_user addevent summary "GHA test event" start $(date '+%FT%T.%N%:z' -d "now + 1 hour") end $(date '+%FT%T.%N%:z' -d "now + 2 hours") attendee $newgroup hangoutsmeet guestscanmodify true sendupdates all
|
|
$gam calendar $gam_user printevents after -0d
|
|
matterid=uid:$($gam create vaultmatter name "GHA matter $newbase" description "test matter" collaborators $newuser | head -1 | cut -d ' ' -f 3)
|
|
$gam create vaulthold matter $matterid name "GHA hold $newbase" corpus mail accounts $newuser
|
|
$gam print vaultmatters matterstate open
|
|
$gam print vaultholds matter $matterid
|
|
$gam print vaultcount matter $matterid corpus mail everyone todrive
|
|
$gam create vaultexport matter $matterid name "GHA export $newbase" corpus mail accounts $newuser
|
|
$gam print exports matter $matterid | $gam csv - gam info export $matterid id:~~id~~
|
|
$gam csv sample.csv gam user ~email add calendar id:$newresource
|
|
$gam delete resource $newresource
|
|
$gam delete feature Whiteboard-$newbase
|
|
$gam delete feature VC-$newbase
|
|
$gam delete building $newbuilding
|
|
$gam delete group $newgroup
|
|
$gam create alias $newalias user $newuser
|
|
$gam user $newuser delete license workspaceenterpriseplus
|
|
$gam whatis $newuser
|
|
$gam user $gam_user show tokens
|
|
$gam print exports matter $matterid | $gam csv - gam download export $matterid id:~~id~~
|
|
$gam delete hold "GHA hold $newbase" matter $matterid
|
|
$gam update matter $matterid action close
|
|
$gam update matter $matterid action delete
|
|
$gam delete user $newuser
|
|
$gam print users query "gha.jid=$JID" | $gam csv - gam delete user ~primaryEmail
|
|
$gam print mobile
|
|
$gam print devices
|
|
$gam print browsers
|
|
export sn="$JID$JID$JID$JID-$(openssl rand -base64 32 | sed 's/[^a-zA-Z0-9]//g')"
|
|
$gam create device serialnumber $sn devicetype android
|
|
$gam print cros allfields orderby serialnumber
|
|
#$gam show crostelemetry storagepercentonly
|
|
$gam report usageparameters customer
|
|
$gam report usage customer parameters gmail:num_emails_sent,accounts:num_1day_logins
|
|
$gam report customer todrive
|
|
$gam report users fields accounts:is_less_secure_apps_access_allowed,gmail:last_imap_time,gmail:last_pop_time filters "accounts:last_login_time>2019-01-01T00:00:00.000Z" todrive
|
|
$gam report admin start -3d todrive
|
|
$gam print devices nopersonaldevices nodeviceusers filter "serial:$JID$JID$JID$JID-" | $gam csv - gam delete device id ~name
|
|
$gam print userinvitations
|
|
$gam print userinvitations | $gam csv - gam send userinvitation ~name
|
|
export CUSTOMER_ID="C01wfv983"
|
|
export GA_DOMAIN="pdl.jaylee.us"
|
|
touch $gampath/enabledasa.txt
|
|
echo "printer model count:"
|
|
$gam print printermodels | wc -l
|
|
#$gam print printers
|
|
#$gam create printer displayname "${newbase}" uri ipp://localhost:631 driverless description "made by $(date)"
|
|
rm $gampath/enabledasa.txt
|
|
|
|
- name: Upload to Google Drive, build only.
|
|
if: github.event_name == 'push' && matrix.goal != 'test'
|
|
run: |
|
|
ls gam-$GAMVERSION-*
|
|
for gamfile in gam-$GAMVERSION-*; do
|
|
echo "Uploading file ${gamfile} to Google Drive..."
|
|
fileid=$($gam user $gam_user add drivefile localfile $gamfile drivefilename $GAMVERSION-${GITHUB_SHA:0:7}-$gamfile parentid 1N2zbO33qzUQFsGM49-m9AQC1ijzd_ru1 returnidonly)
|
|
echo "file uploaded as ${fileid}, setting ACL..."
|
|
$gam user $gam_user add drivefileacl $fileid anyone role reader withlink
|
|
done
|
|
|
|
- name: Archive production artifacts
|
|
uses: actions/upload-artifact@v2
|
|
if: github.event_name == 'push' && matrix.goal != 'test'
|
|
with:
|
|
name: gam-binaries
|
|
path: |
|
|
src/*.tar.xz
|
|
src/*.zip
|
|
src/*.msi
|