1- """AppVeyor Build
1+ """Github Action Build
22
3- This file is used to build and distribute the safety binary on appveyor. Take
4- a look at the corresponding appveyor .yml as well.
3+ This file is used to build and distribute the safety binary on Github actions.
4+ Take a look at the corresponding main .yml as well.
55
66"""
77import os
@@ -18,35 +18,38 @@ class environment:
1818
1919 def __init__ (self ):
2020 os_mapping = {
21- "Visual Studio 2019 " : self .WIN ,
22- "Ubuntu " : self .LINUX ,
23- "macOS " : self .MACOS
21+ "windows-latest " : self .WIN ,
22+ "ubuntu-latest " : self .LINUX ,
23+ "macos-latest " : self .MACOS
2424 }
25- self .os = os_mapping [os .getenv ("APPVEYOR_BUILD_WORKER_IMAGE " )]
25+ self .os = os_mapping [os .getenv ("BINARY_OS " )]
2626
2727 @property
2828 def python (self ):
2929 for arch , python in self .PYTHON_BINARIES [self .os ].items ():
3030 yield arch , python
3131
32+ WIN_BASE_PATH = "C:\\ hostedtoolcache\\ windows\\ Python\\ 3.10.7"
33+
3234 PYTHON_BINARIES = {
3335 WIN : {
34- 64 : "C: \\ Python38- x64\\ python.exe" ,
35- 32 : "C: \\ Python38 \\ python.exe",
36+ 64 : f" { WIN_BASE_PATH } \\ x64\\ python.exe" , # setup-python default
37+ 32 : f" { WIN_BASE_PATH } \\ x86 \\ python.exe"
3638 },
3739
3840 # Order is important. If the 32 bit release gets built first,
3941 # you'll run into permission problems due to docker clobbering
4042 # up the current working directory.
4143 LINUX : OrderedDict ([
42- (64 , "python" ),
43- (32 , f"docker run -t -v { os .getcwd ()} :/app 32-bit-linux python3" ),
44+ (64 , "python3" ),
45+ (32 ,
46+ f"docker run --platform linux/386 -t "
47+ f"-v { os .getcwd ()} :/app 32-bit-linux "
48+ f"python3" ),
4449 ]),
4550
4651 MACOS : {
47- # Trying to use Python 3 compatible with PyInstaller according
48- # https://www.appveyor.com/docs/macos-images-software/#python
49- 64 : "~/venv3.8/bin/python" ,
52+ 64 : "python3" ,
5053 }
5154 }
5255
@@ -59,7 +62,10 @@ def run(self, command):
5962 try :
6063 print (f"RUNNING: { command } " )
6164 print ("-" * 80 )
62- subprocess .run (command , shell = True , check = True )
65+ result = subprocess .run (command , shell = True , check = True ,
66+ stdout = subprocess .PIPE )
67+ if result :
68+ print (result .stdout .decode ('utf-8' ).strip ())
6369 except subprocess .CalledProcessError as e :
6470 print (f"ERROR calling '{ command } '" )
6571 print ("-" * 20 )
@@ -74,13 +80,12 @@ def install(self):
7480 # - build the 32 bit binary for linux on docker
7581 # - create dist/ path to circumvent permission errors
7682 if self .os == self .LINUX :
77- self .run ("docker build -t 32-bit-linux -f Dockerfilei386 ." )
83+ self .run ("docker build --platform linux/386 "
84+ "-t 32-bit-linux -f Dockerfilei386 ." )
7885
7986 for arch , python in self .python :
80- self .run (f"{ python } -m pip install setuptools" )
8187 self .run (f"{ python } -m pip install pyinstaller" )
82- self .run (f"{ python } -m pip install pytest" )
83- self .run (f"{ python } -m pip install -e ." )
88+ self .run (f"{ python } -m pip install -r test_requirements.txt" )
8489
8590 def dist (self ):
8691 """Runs Pyinstaller producing a binary for every platform arch."""
@@ -92,7 +97,7 @@ def dist(self):
9297 f" --distpath { build_path } " )
9398
9499 # There seems to be no way to tell pyinstaller the binary name.
95- # This leads to problems with appveyors artifact collector because
100+ # This leads to problems with artifact collector because
96101 # every binary is named the same.
97102 #
98103 # Move them around so they can be picked up correctly
@@ -113,13 +118,13 @@ def test(self):
113118 Runs tests for every available arch on the current platform.
114119 """
115120 for arch , python in self .python :
116- self .run (f"{ python } -m pytest" )
121+ self .run (f"{ python } -m pytest --log-level=DEBUG " )
117122
118123
119124if __name__ == "__main__" :
120125
121126 if len (sys .argv ) <= 1 or sys .argv [1 ] not in ['install' , 'test' , 'dist' ]:
122- print ("usage: appveyor .py [install|test|dist]" )
127+ print ("usage: binaries .py [install|test|dist]" )
123128 sys .exit (- 1 )
124129
125130 env = environment ()
0 commit comments