From 94fa88266b8c2ef5695425ee8edf155779e8ca64 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Mon, 25 Nov 2019 16:19:06 +0100 Subject: [PATCH 01/18] Run tests with Github Actions --- .github/workflows/run-tests.yml | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/run-tests.yml diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 000000000..f4b2d6dc0 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,37 @@ +name: Run tests + +on: [push] + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + python-version: [3.5, 3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - name: Check coding style + run: | + pip install flake8 isort + flake8 picard --count --show-source --statistics + isort --check-only --diff --recursive picard test + - name: Test with pytest + run: | + pip install pytest pytest-randomly pytest-cov + pytest --verbose --cov=picard --cov-report xml:coverage.xml test + # - name: Submit code coverage to codacy + # if: secrets.CODACY_PROJECT_TOKEN + # run: | + # pip install codacy-coverage + # python-codacy-coverage -r coverage.xml From 1ce769983f782dbb126ec2ff2b53db8204d4d877 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Mon, 25 Nov 2019 16:58:44 +0100 Subject: [PATCH 02/18] Github Actions: Package macOS app --- .github/workflows/package-macos.yml | 32 +++++++++++++++++++++++++++++ scripts/package/macos-setup.sh | 8 +++++--- 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/package-macos.yml diff --git a/.github/workflows/package-macos.yml b/.github/workflows/package-macos.yml new file mode 100644 index 000000000..387177247 --- /dev/null +++ b/.github/workflows/package-macos.yml @@ -0,0 +1,32 @@ +name: Package for macOS + +on: [push] + +jobs: + package: + + runs-on: macos-latest + + steps: + - uses: actions/checkout@v1 + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: Setup macOS build environment + run: | + ./scripts/package/macos-setup.sh + env: + DISCID_VERSION: 0.6.2 + FPCALC_VERSION: 1.4.3 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + source bin/activate + pip install -r requirements-macos.txt + - name: Build macOS app + run: | + source bin/activate + ./scripts/package/macos-package-app.sh + env: + UPLOAD_OSX: 1 diff --git a/scripts/package/macos-setup.sh b/scripts/package/macos-setup.sh index 5c6f72a0a..82e201942 100755 --- a/scripts/package/macos-setup.sh +++ b/scripts/package/macos-setup.sh @@ -7,9 +7,11 @@ brew install gettext brew link gettext --force # Install requested Python version -wget "https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-macosx10.9.pkg" -sudo installer -pkg python-${PYTHON_VERSION}-macosx10.9.pkg -target / -sudo python3 -m ensurepip +if [ -n "$PYTHON_VERSION" ]; then + wget "https://www.python.org/ftp/python/${PYTHON_VERSION}/python-${PYTHON_VERSION}-macosx10.9.pkg" + sudo installer -pkg python-${PYTHON_VERSION}-macosx10.9.pkg -target / + sudo python3 -m ensurepip +fi # Install libdiscid wget "ftp://ftp.musicbrainz.org/pub/musicbrainz/libdiscid/libdiscid-$DISCID_VERSION.tar.gz" From e2e3c1d7cdcb157d8a09e84e7de60d96aae6632e Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Mon, 25 Nov 2019 21:17:12 +0100 Subject: [PATCH 03/18] Github Actions: Package Windows app --- .github/workflows/package-windows.yml | 43 +++++++++++++++++++++++ scripts/package/win-package-appx.ps1 | 4 +++ scripts/package/win-package-installer.ps1 | 4 +++ scripts/package/win-package-portable.ps1 | 4 +++ scripts/package/win-setup.ps1 | 39 ++++++++++++++++++++ 5 files changed, 94 insertions(+) create mode 100644 .github/workflows/package-windows.yml create mode 100644 scripts/package/win-setup.ps1 diff --git a/.github/workflows/package-windows.yml b/.github/workflows/package-windows.yml new file mode 100644 index 000000000..7df475c44 --- /dev/null +++ b/.github/workflows/package-windows.yml @@ -0,0 +1,43 @@ +name: Package for Windows + +on: [push] + +jobs: + package: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v1 + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: Setup Windows build environment + run: | + & .\scripts\package\win-setup.ps1 -DiscidVersion $Env:DISCID_VERSION -FpcalVersion $Env:FPCALC_VERSION + env: + DISCID_VERSION: 0.6.2 + FPCALC_VERSION: 1.4.3 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-build.txt + pip install -r requirements-win.txt + - name: Build Windows 10 app package + run: | + $Env:PATH += ";C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64" + $Certificate = @(Get-ChildItem cert:\CurrentUser\My -codesign)[0] + & .\scripts\package\win-package-appx.ps1 -BuildNumber $(git rev-list --count HEAD) -Certificate $Certificate + - name: Build Windows installer + if: always() + run: | + choco install nsis + $Certificate = @(Get-ChildItem cert:\CurrentUser\My -codesign)[0] + & .\scripts\package\win-package-installer.ps1 -BuildNumber $(git rev-list --count HEAD) -Certificate $Certificate + dist\picard\fpcalc -version + - name: Build Windows portable app + if: always() + run: | + $Certificate = @(Get-ChildItem cert:\CurrentUser\My -codesign)[0] + & .\scripts\package\win-package-portable.ps1 -BuildNumber $(git rev-list --count HEAD) -Certificate $Certificate diff --git a/scripts/package/win-package-appx.ps1 b/scripts/package/win-package-appx.ps1 index 392b88442..cde5ac039 100644 --- a/scripts/package/win-package-appx.ps1 +++ b/scripts/package/win-package-appx.ps1 @@ -7,6 +7,10 @@ Param( $BuildNumber ) +# Errors are handled explicitly. Otherwise any output to stderr when +# calling classic Windows exes causes a script error. +$ErrorActionPreference = 'Continue' + If (-Not $BuildNumber) { $BuildNumber = 0 } diff --git a/scripts/package/win-package-installer.ps1 b/scripts/package/win-package-installer.ps1 index 1efb752e3..5a075bb97 100644 --- a/scripts/package/win-package-installer.ps1 +++ b/scripts/package/win-package-installer.ps1 @@ -7,6 +7,10 @@ Param( $BuildNumber ) +# Errors are handled explicitly. Otherwise any output to stderr when +# calling classic Windows exes causes a script error. +$ErrorActionPreference = 'Continue' + If (-Not $BuildNumber) { $BuildNumber = 0 } diff --git a/scripts/package/win-package-portable.ps1 b/scripts/package/win-package-portable.ps1 index afe333338..8b5394eed 100644 --- a/scripts/package/win-package-portable.ps1 +++ b/scripts/package/win-package-portable.ps1 @@ -7,6 +7,10 @@ Param( $BuildNumber ) +# Errors are handled explicitly. Otherwise any output to stderr when +# calling classic Windows exes causes a script error. +$ErrorActionPreference = 'Continue' + If (-Not $BuildNumber) { $BuildNumber = 0 } diff --git a/scripts/package/win-setup.ps1 b/scripts/package/win-setup.ps1 new file mode 100644 index 000000000..ea2c49ff7 --- /dev/null +++ b/scripts/package/win-setup.ps1 @@ -0,0 +1,39 @@ +Param( + [Parameter(Mandatory=$true)] + [String] + $DiscidVersion, + [Parameter(Mandatory=$true)] + [String] + $FpcalVersion +) + +$ErrorActionPreference = "Stop" + +Function DownloadFile { + Param( + [Parameter(Mandatory=$true)] + [String] + $FileName, + [Parameter(Mandatory=$true)] + [String] + $Url + ) + $OutputPath = (Join-Path (Resolve-Path .) $FileName) + (New-Object System.Net.WebClient).DownloadFile($Url, "$OutputPath") +} + +New-Item -Name .\build -ItemType Directory -ErrorAction Ignore + +$ArchiveFile = ".\build\libdiscid.zip" +Write-Output "Downloading libdiscid to $ArchiveFile..." +DownloadFile -Url "https://github.com/metabrainz/libdiscid/releases/download/v$DiscidVersion/libdiscid-$DiscidVersion-win64.zip" ` + -FileName $ArchiveFile +Expand-Archive -Path $ArchiveFile -DestinationPath .\build\libdiscid -Force +Copy-Item .\build\libdiscid\discid.dll . + +$ArchiveFile = ".\build\fpcalc.zip" +Write-Output "Downloading chromaprint-fpcalc to $ArchiveFile..." +DownloadFile -Url "https://github.com/acoustid/chromaprint/releases/download/v$FpcalVersion/chromaprint-fpcalc-$FpcalVersion-windows-x86_64.zip" ` + -FileName $ArchiveFile +Expand-Archive -Path $ArchiveFile -DestinationPath .\build\fpcalc -Force +Copy-Item .\build\fpcalc\chromaprint-fpcalc-$FpcalVersion-windows-x86_64\fpcalc.exe . From c43020973d31c68fc5163999f4db2963ea4ef448 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Mon, 25 Nov 2019 22:24:08 +0100 Subject: [PATCH 04/18] Github Actions: Upload build artifacts --- .github/workflows/package-macos.yml | 10 ++++++++-- .github/workflows/package-windows.yml | 10 ++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package-macos.yml b/.github/workflows/package-macos.yml index 387177247..e0580e71f 100644 --- a/.github/workflows/package-macos.yml +++ b/.github/workflows/package-macos.yml @@ -16,6 +16,7 @@ jobs: - name: Setup macOS build environment run: | ./scripts/package/macos-setup.sh + mkdir artifacts env: DISCID_VERSION: 0.6.2 FPCALC_VERSION: 1.4.3 @@ -28,5 +29,10 @@ jobs: run: | source bin/activate ./scripts/package/macos-package-app.sh - env: - UPLOAD_OSX: 1 + mv dist/*.dmg artifacts/ + - name: Archive production artifacts + uses: actions/upload-artifact@v1 + if: always() + with: + name: macos-builds + path: artifacts/ diff --git a/.github/workflows/package-windows.yml b/.github/workflows/package-windows.yml index 7df475c44..3a0ce94a5 100644 --- a/.github/workflows/package-windows.yml +++ b/.github/workflows/package-windows.yml @@ -16,6 +16,7 @@ jobs: - name: Setup Windows build environment run: | & .\scripts\package\win-setup.ps1 -DiscidVersion $Env:DISCID_VERSION -FpcalVersion $Env:FPCALC_VERSION + New-Item -Name .\artifacts -ItemType Directory env: DISCID_VERSION: 0.6.2 FPCALC_VERSION: 1.4.3 @@ -29,15 +30,24 @@ jobs: $Env:PATH += ";C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64" $Certificate = @(Get-ChildItem cert:\CurrentUser\My -codesign)[0] & .\scripts\package\win-package-appx.ps1 -BuildNumber $(git rev-list --count HEAD) -Certificate $Certificate + Move-Item .\dist\*.msix .\artifacts - name: Build Windows installer if: always() run: | choco install nsis $Certificate = @(Get-ChildItem cert:\CurrentUser\My -codesign)[0] & .\scripts\package\win-package-installer.ps1 -BuildNumber $(git rev-list --count HEAD) -Certificate $Certificate + Move-Item .\installer\*.exe .\artifacts dist\picard\fpcalc -version - name: Build Windows portable app if: always() run: | $Certificate = @(Get-ChildItem cert:\CurrentUser\My -codesign)[0] & .\scripts\package\win-package-portable.ps1 -BuildNumber $(git rev-list --count HEAD) -Certificate $Certificate + Move-Item .\dist\*.exe .\artifacts + - name: Archive production artifacts + uses: actions/upload-artifact@v1 + if: always() + with: + name: windows-builds + path: artifacts/ From 69af7e326db464b23f2dfaffc6c66f7a9e9917c2 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Mon, 25 Nov 2019 22:42:05 +0100 Subject: [PATCH 05/18] Github Actions: Upload artifacts to Github releases --- .github/workflows/package-macos.yml | 7 +++++++ .github/workflows/package-windows.yml | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/.github/workflows/package-macos.yml b/.github/workflows/package-macos.yml index e0580e71f..e7da3245a 100644 --- a/.github/workflows/package-macos.yml +++ b/.github/workflows/package-macos.yml @@ -36,3 +36,10 @@ jobs: with: name: macos-builds path: artifacts/ + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: artifacts/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/package-windows.yml b/.github/workflows/package-windows.yml index 3a0ce94a5..1513c574b 100644 --- a/.github/workflows/package-windows.yml +++ b/.github/workflows/package-windows.yml @@ -51,3 +51,10 @@ jobs: with: name: windows-builds path: artifacts/ + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + files: artifacts/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 05bcd89b0ef412f904a81c8a9d84ea3e4e83d69a Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Mon, 25 Nov 2019 22:53:07 +0100 Subject: [PATCH 06/18] Github Actions: Windows code signing --- .github/workflows/package-windows.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/package-windows.yml b/.github/workflows/package-windows.yml index 1513c574b..9126c7d5d 100644 --- a/.github/workflows/package-windows.yml +++ b/.github/workflows/package-windows.yml @@ -20,6 +20,18 @@ jobs: env: DISCID_VERSION: 0.6.2 FPCALC_VERSION: 1.4.3 + - name: Prepare code signing certificate + run: | + pip install awscli + aws s3 cp "$Env:CODESIGN_PFX_URL" .\codesign.pfx + $CertPassword = ConvertTo-SecureString -String $Env:CODESIGN_PFX_PASSWORD -Force -AsPlainText + Import-PfxCertificate -CertStoreLocation Cert:\CurrentUser\My -FilePath .\codesign.pfx -Password $CertPassword + env: + AWS_DEFAULT_REGION: eu-central-1 + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + CODESIGN_PFX_URL: ${{ secrets.CODESIGN_PFX_URL }} + CODESIGN_PFX_PASSWORD: ${{ secrets.CODESIGN_PFX_PASSWORD }} - name: Install dependencies run: | python -m pip install --upgrade pip From 7827b1bf16164d46c803d6cdc9cb2a19bbb206f1 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Mon, 25 Nov 2019 23:34:25 +0100 Subject: [PATCH 07/18] Github Actions: Use Get-PfxCertificate to open code sign certificate Import-PfxCertificate is not available on Github Actions. --- .github/workflows/package-windows.yml | 20 ++++++++++++-------- scripts/package/win-package-appx.ps1 | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/workflows/package-windows.yml b/.github/workflows/package-windows.yml index 9126c7d5d..070eaa53b 100644 --- a/.github/workflows/package-windows.yml +++ b/.github/workflows/package-windows.yml @@ -24,14 +24,11 @@ jobs: run: | pip install awscli aws s3 cp "$Env:CODESIGN_PFX_URL" .\codesign.pfx - $CertPassword = ConvertTo-SecureString -String $Env:CODESIGN_PFX_PASSWORD -Force -AsPlainText - Import-PfxCertificate -CertStoreLocation Cert:\CurrentUser\My -FilePath .\codesign.pfx -Password $CertPassword env: AWS_DEFAULT_REGION: eu-central-1 AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} CODESIGN_PFX_URL: ${{ secrets.CODESIGN_PFX_URL }} - CODESIGN_PFX_PASSWORD: ${{ secrets.CODESIGN_PFX_PASSWORD }} - name: Install dependencies run: | python -m pip install --upgrade pip @@ -40,23 +37,30 @@ jobs: - name: Build Windows 10 app package run: | $Env:PATH += ";C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64" - $Certificate = @(Get-ChildItem cert:\CurrentUser\My -codesign)[0] - & .\scripts\package\win-package-appx.ps1 -BuildNumber $(git rev-list --count HEAD) -Certificate $Certificate + & .\scripts\package\win-package-appx.ps1 -BuildNumber $(git rev-list --count HEAD) -CertificateFile .\codesign.pfx -CertificatePassword $Env:CODESIGN_PFX_PASSWORD Move-Item .\dist\*.msix .\artifacts + env: + CODESIGN_PFX_PASSWORD: ${{ secrets.CODESIGN_PFX_PASSWORD }} - name: Build Windows installer if: always() run: | - choco install nsis - $Certificate = @(Get-ChildItem cert:\CurrentUser\My -codesign)[0] + # choco install nsis + $CertPassword = ConvertTo-SecureString -String $Env:CODESIGN_PFX_PASSWORD -Force -AsPlainText + $Certificate = Get-PfxCertificate -FilePath .\codesign.pfx -Password $CertPassword & .\scripts\package\win-package-installer.ps1 -BuildNumber $(git rev-list --count HEAD) -Certificate $Certificate Move-Item .\installer\*.exe .\artifacts dist\picard\fpcalc -version + env: + CODESIGN_PFX_PASSWORD: ${{ secrets.CODESIGN_PFX_PASSWORD }} - name: Build Windows portable app if: always() run: | - $Certificate = @(Get-ChildItem cert:\CurrentUser\My -codesign)[0] + $CertPassword = ConvertTo-SecureString -String $Env:CODESIGN_PFX_PASSWORD -Force -AsPlainText + $Certificate = Get-PfxCertificate -FilePath .\codesign.pfx -Password $CertPassword & .\scripts\package\win-package-portable.ps1 -BuildNumber $(git rev-list --count HEAD) -Certificate $Certificate Move-Item .\dist\*.exe .\artifacts + env: + CODESIGN_PFX_PASSWORD: ${{ secrets.CODESIGN_PFX_PASSWORD }} - name: Archive production artifacts uses: actions/upload-artifact@v1 if: always() diff --git a/scripts/package/win-package-appx.ps1 b/scripts/package/win-package-appx.ps1 index cde5ac039..0a8c8e987 100644 --- a/scripts/package/win-package-appx.ps1 +++ b/scripts/package/win-package-appx.ps1 @@ -3,6 +3,11 @@ Param( [System.Security.Cryptography.X509Certificates.X509Certificate] $Certificate, + [ValidateScript({Test-Path $_ -PathType Leaf})] + [String] + $CertificateFile, + [String] + $CertificatePassword, [Int] $BuildNumber ) @@ -15,6 +20,11 @@ If (-Not $BuildNumber) { $BuildNumber = 0 } +If (-Not $Certificate -And $CertificateFile) { + $CertPassword = ConvertTo-SecureString -String $CertificatePassword -Force -AsPlainText + $Certificate = Get-PfxCertificate -FilePath $CertificateFile -Password $CertPassword +} + $ScriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent . $ScriptDirectory\win-common.ps1 -Certificate $Certificate @@ -52,7 +62,10 @@ MakeAppx pack /o /h SHA256 /d $PackageDir /p $PackageFile ThrowOnExeError "MakeAppx failed" # Sign package -If ($Certificate) { +If ($CertificateFile) { + SignTool sign /fd SHA256 /f "$CertificateFile" /p "$CertificatePassword" $PackageFile + ThrowOnExeError "SignTool failed" +} ElseIf ($Certificate) { SignTool sign /fd SHA256 /sha1 $Certificate.Thumbprint $PackageFile ThrowOnExeError "SignTool failed" } From a24e84f3bdb367e4cb0dd271ef3e7d886cfeab29 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Tue, 26 Nov 2019 00:20:13 +0100 Subject: [PATCH 08/18] Github Actions: Add git commit hash to version for non-release builds --- .github/workflows/package-macos.yml | 4 ++++ .github/workflows/package-windows.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/package-macos.yml b/.github/workflows/package-macos.yml index e7da3245a..fba053b6c 100644 --- a/.github/workflows/package-macos.yml +++ b/.github/workflows/package-macos.yml @@ -13,6 +13,10 @@ jobs: uses: actions/setup-python@v1 with: python-version: 3.7 + - name: Patch build version + if: startsWith(github.ref, 'refs/tags/') != true + run: | + python setup.py patch_version --platform=$(git rev-list --count HEAD).$(git rev-parse --short HEAD) - name: Setup macOS build environment run: | ./scripts/package/macos-setup.sh diff --git a/.github/workflows/package-windows.yml b/.github/workflows/package-windows.yml index 070eaa53b..6113b5c2a 100644 --- a/.github/workflows/package-windows.yml +++ b/.github/workflows/package-windows.yml @@ -13,6 +13,10 @@ jobs: uses: actions/setup-python@v1 with: python-version: 3.7 + - name: Patch build version + if: startsWith(github.ref, 'refs/tags/') != true + run: | + python setup.py patch_version --platform=$(git rev-list --count HEAD).$(git rev-parse --short HEAD) - name: Setup Windows build environment run: | & .\scripts\package\win-setup.ps1 -DiscidVersion $Env:DISCID_VERSION -FpcalVersion $Env:FPCALC_VERSION From 23759d88182cd884838f1547044fa78e11479c43 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Tue, 26 Nov 2019 08:10:25 +0100 Subject: [PATCH 09/18] Github Actions: Submit code coverage reports to Codacy --- .github/workflows/run-tests.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index f4b2d6dc0..a97bdaaaf 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -10,6 +10,8 @@ jobs: matrix: os: [macos-latest, ubuntu-latest, windows-latest] python-version: [3.5, 3.6, 3.7, 3.8] + env: + CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} steps: - uses: actions/checkout@v1 @@ -30,8 +32,8 @@ jobs: run: | pip install pytest pytest-randomly pytest-cov pytest --verbose --cov=picard --cov-report xml:coverage.xml test - # - name: Submit code coverage to codacy - # if: secrets.CODACY_PROJECT_TOKEN - # run: | - # pip install codacy-coverage - # python-codacy-coverage -r coverage.xml + - name: Submit code coverage to Codacy + if: env.CODACY_PROJECT_TOKEN + run: | + pip install codacy-coverage + python-codacy-coverage -r coverage.xml From 52c6632354467f5020bf1be966ac418904879024 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Tue, 26 Nov 2019 09:03:46 +0100 Subject: [PATCH 10/18] Github Actions: Setup macOS code signing --- .github/workflows/package-macos.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/package-macos.yml b/.github/workflows/package-macos.yml index fba053b6c..c9426ab31 100644 --- a/.github/workflows/package-macos.yml +++ b/.github/workflows/package-macos.yml @@ -34,6 +34,12 @@ jobs: source bin/activate ./scripts/package/macos-package-app.sh mv dist/*.dmg artifacts/ + env: + APPLE_ID_USER: ${{ secrets. APPLE_ID_USER }} + APPLE_ID_PASSWORD: ${{ secrets. APPLE_ID_PASSWORD }} + encrypted_be5fb2212036_key: ${{ secrets.CODESIGN_MACOS_ENCRYPTED_KEY }} + encrypted_be5fb2212036_iv: ${{ secrets.CODESIGN_MACOS_ENCRYPTED_IV }} + appledev_p12_password: ${{ secrets.CODESIGN_MACOS_P12_PASSWORD }} - name: Archive production artifacts uses: actions/upload-artifact@v1 if: always() From c4f9ced8254ea9beb72143589e6343535fd72ded Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Tue, 26 Nov 2019 11:31:12 +0100 Subject: [PATCH 11/18] Github Actions: Test clean pip install from source --- .github/workflows/run-tests.yml | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a97bdaaaf..c1db37a91 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -4,7 +4,6 @@ on: [push] jobs: build: - runs-on: ${{ matrix.os }} strategy: matrix: @@ -37,3 +36,29 @@ jobs: run: | pip install codacy-coverage python-codacy-coverage -r coverage.xml + + pip-install: # Test whether a clean pip install from source works + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + python-version: [3.8] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install gettext (Linux) + if: runner.os == 'Linux' + run: sudo apt-get install gettext + - name: Install gettext (macOS) + if: runner.os == 'macOS' + run: | + brew install gettext + brew link gettext --force + - name: Run pip install . + run: | + python -m pip install --upgrade pip + pip install . From bb809846e673cc6d8b56ab13b61c620e6a2881ef Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Tue, 26 Nov 2019 14:37:53 +0100 Subject: [PATCH 12/18] macos-package-app: Run patch_version only on Travis This is handled separately for Github Actions --- scripts/package/macos-package-app.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/package/macos-package-app.sh b/scripts/package/macos-package-app.sh index 7fb41b079..e710f7cf0 100755 --- a/scripts/package/macos-package-app.sh +++ b/scripts/package/macos-package-app.sh @@ -1,8 +1,7 @@ #!/usr/bin/env bash set -e -if [ -z "$TRAVIS_TAG" ] -then +if [ -z "$TRAVIS_TAG" ] && [ -n "$TRAVIS_OSX_IMAGE" ]; then python3 setup.py patch_version --platform=osx.$TRAVIS_OSX_IMAGE fi VERSION=$(python3 -c 'import picard; print(picard.__version__)') From 4c7a93e7e28718f7daf6c4577a8008dcaca4001d Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Tue, 26 Nov 2019 14:41:04 +0100 Subject: [PATCH 13/18] Avoid spaces in filenames for binary builds --- scripts/package/macos-package-app.sh | 6 +++++- scripts/package/win-package-appx.ps1 | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/package/macos-package-app.sh b/scripts/package/macos-package-app.sh index e710f7cf0..febeac4d0 100755 --- a/scripts/package/macos-package-app.sh +++ b/scripts/package/macos-package-app.sh @@ -77,7 +77,11 @@ LIBDISCID_REGEX="libdiscid [0-9]+\.[0-9]+\.[0-9]+" "MusicBrainz Picard.app/Contents/MacOS/fpcalc" -version # Package app bundle into DMG image -DMG="MusicBrainz Picard $VERSION macOS $MACOS_VERSION_MAJOR.$MACOS_VERSION_MINOR.dmg" +if [ -n "$TRAVIS_OSX_IMAGE" ]; then + DMG="MusicBrainz-Picard-${VERSION}_macOS-$MACOS_VERSION_MAJOR.$MACOS_VERSION_MINOR.dmg" +else + DMG="MusicBrainz-Picard-$VERSION.dmg" +fi hdiutil create -volname "MusicBrainz Picard $VERSION" \ -srcfolder 'MusicBrainz Picard.app' -ov -format UDBZ "$DMG" [ "$CODESIGN" = '1' ] && codesign --verify --verbose \ diff --git a/scripts/package/win-package-appx.ps1 b/scripts/package/win-package-appx.ps1 index 0a8c8e987..10efebcc3 100644 --- a/scripts/package/win-package-appx.ps1 +++ b/scripts/package/win-package-appx.ps1 @@ -57,7 +57,7 @@ Pop-Location # Generate msix package $PicardVersion = (python -c "import picard; print(picard.__version__)") -$PackageFile = "dist\MusicBrainz Picard $PicardVersion.msix" +$PackageFile = "dist\MusicBrainz-Picard-$PicardVersion.msix" MakeAppx pack /o /h SHA256 /d $PackageDir /p $PackageFile ThrowOnExeError "MakeAppx failed" From a4c123bc2593f0a44b7caf4936e3fe0a6468aea3 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Wed, 27 Nov 2019 07:58:29 +0100 Subject: [PATCH 14/18] Github Actions: Limit paths for which to run tests / packaging --- .github/workflows/package-macos.yml | 15 ++++++++++++++- .github/workflows/package-windows.yml | 18 +++++++++++++++++- .github/workflows/run-tests.yml | 19 ++++++++++++++++++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/.github/workflows/package-macos.yml b/.github/workflows/package-macos.yml index c9426ab31..b0f7eb04d 100644 --- a/.github/workflows/package-macos.yml +++ b/.github/workflows/package-macos.yml @@ -1,6 +1,19 @@ name: Package for macOS -on: [push] +on: + push: + paths: + - '.github/workflows/package-macos.yml' + - 'picard/**' + - 'po/**.po' + - 'resources/win10/**' + - '!scripts/package/*.ps1' + - 'scripts/pyinstaller/*' + - 'picard.icns' + - 'picard.spec' + - 'requirements*.txt' + - 'setup.py' + - 'tagger.py.in' jobs: package: diff --git a/.github/workflows/package-windows.yml b/.github/workflows/package-windows.yml index 6113b5c2a..b2cbc530c 100644 --- a/.github/workflows/package-windows.yml +++ b/.github/workflows/package-windows.yml @@ -1,6 +1,22 @@ name: Package for Windows -on: [push] +on: + push: + paths: + - '.github/workflows/package-windows.yml' + - 'installer/**' + - 'picard/**' + - 'po/**.po' + - 'resources/win10/**' + - 'scripts/package/*.ps1' + - 'scripts/pyinstaller/*' + - 'appxmanifest.xml.in' + - 'picard.ico' + - 'picard.spec' + - 'requirements*.txt' + - 'setup.py' + - 'tagger.py.in' + - 'win.version-info.txt.in' jobs: package: diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index c1db37a91..0834640af 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,6 +1,23 @@ name: Run tests -on: [push] +on: + push: + paths-ignore: + - '.github/*.yml' + - '.tx/**' + - 'installer/**' + - 'resources/**' + - 'scripts/package/**' + - 'scripts/pyinstaller/**' + - 'ui/**' + - '.*' + - '*.icns' + - '*.ico' + - '*.txt' + - '**.md' + - 'appveyor.yml' + - 'appxmanifest.xml.in' + - 'win-version-info.txt.in' jobs: build: From 89d6097125f08f41104c403d96762bc08aa08ece Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Wed, 27 Nov 2019 08:57:14 +0100 Subject: [PATCH 15/18] Github Actions: Run tests even if code style validation fails The test suite will still fail, but we get all issues reported instead of just code style issues. --- .github/workflows/run-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 0834640af..bafc2d3ae 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -45,6 +45,7 @@ jobs: flake8 picard --count --show-source --statistics isort --check-only --diff --recursive picard test - name: Test with pytest + if: always() run: | pip install pytest pytest-randomly pytest-cov pytest --verbose --cov=picard --cov-report xml:coverage.xml test From 77ca6a7bc5ce4eded637d0a4c78a3a125be2c0ee Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Wed, 27 Nov 2019 10:04:22 +0100 Subject: [PATCH 16/18] Github Actions: Ensure win / mac builds are triggered for release tags --- .github/workflows/package-macos.yml | 5 ++++- .github/workflows/package-windows.yml | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package-macos.yml b/.github/workflows/package-macos.yml index b0f7eb04d..6daf4de86 100644 --- a/.github/workflows/package-macos.yml +++ b/.github/workflows/package-macos.yml @@ -14,6 +14,9 @@ on: - 'requirements*.txt' - 'setup.py' - 'tagger.py.in' + create: + tags: + - 'release-*' jobs: package: @@ -61,7 +64,7 @@ jobs: path: artifacts/ - name: Release uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'create' with: files: artifacts/* env: diff --git a/.github/workflows/package-windows.yml b/.github/workflows/package-windows.yml index b2cbc530c..86ed95b77 100644 --- a/.github/workflows/package-windows.yml +++ b/.github/workflows/package-windows.yml @@ -17,6 +17,9 @@ on: - 'setup.py' - 'tagger.py.in' - 'win.version-info.txt.in' + create: + tags: + - 'release-*' jobs: package: @@ -89,7 +92,7 @@ jobs: path: artifacts/ - name: Release uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'create' with: files: artifacts/* env: From d4f4ac0f8fbcf60f0e0d24a20ab741203288aec7 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Wed, 27 Nov 2019 10:10:33 +0100 Subject: [PATCH 17/18] Github Actions: Run test suite on all pushes --- .github/workflows/run-tests.yml | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index bafc2d3ae..3ca543b70 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,23 +1,6 @@ name: Run tests -on: - push: - paths-ignore: - - '.github/*.yml' - - '.tx/**' - - 'installer/**' - - 'resources/**' - - 'scripts/package/**' - - 'scripts/pyinstaller/**' - - 'ui/**' - - '.*' - - '*.icns' - - '*.ico' - - '*.txt' - - '**.md' - - 'appveyor.yml' - - 'appxmanifest.xml.in' - - 'win-version-info.txt.in' +on: push jobs: build: From af68e3fb297856db7cc048cd25b584d51429ddd2 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Thu, 28 Nov 2019 07:58:33 +0100 Subject: [PATCH 18/18] Github Actions: Run picard -V after pip install test --- .github/workflows/run-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 3ca543b70..fb0c906f8 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -63,3 +63,6 @@ jobs: run: | python -m pip install --upgrade pip pip install . + - name: Test running installed package + if: runner.os != 'Windows' + run: picard --long-version