diff --git a/.github/workflows/build-boost-packages.yml b/.github/workflows/build-boost-packages.yml new file mode 100644 index 0000000..68944df --- /dev/null +++ b/.github/workflows/build-boost-packages.yml @@ -0,0 +1,192 @@ +name: Generate Boost package +on: + workflow_dispatch: + inputs: + VERSION: + description: 'Boost version to build and upload' + required: true + default: '1.73.0' + PUBLISH_RELEASES: + description: 'Whether to publish releases' + required: true + default: 'false' + +env: + VERSION: ${{ github.event.inputs.VERSION }} +defaults: + run: + shell: pwsh + +jobs: + build_boost: + name: Build Boost ${{ github.event.inputs.VERSION }} [${{ matrix.os }}] + runs-on: ${{ matrix.os }} + env: + ARTIFACT_NAME: boost-${{ github.event.inputs.VERSION }}-${{ matrix.platform }}-${{ matrix.toolset }}-${{ matrix.architecture }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-16.04 + architecture: x64 + toolset: gcc + platform: linux-16.04 + - os: ubuntu-18.04 + architecture: x64 + toolset: gcc + platform: linux-18.04 + - os: windows-2016 + architecture: x86_64 + toolset: msvc-14.1 + platform: win32 + - os: windows-2019 + architecture: x86_64 + toolset: msvc-14.2 + platform: win32 + + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Build Boost ${{ env.VERSION }} + run: | + ./builders/build-boost.ps1 -Version $env:VERSION ` + -Platform ${{ matrix.platform }} ` + -Architecture ${{ matrix.architecture }} ` + -Toolset ${{ matrix.toolset }} + + - name: Publish artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ env.ARTIFACT_NAME }} + path: ${{ runner.temp }}/artifact + + test_boost: + name: Test Boost ${{ github.event.inputs.VERSION }} [${{ matrix.os }}] + needs: build_boost + runs-on: ${{ matrix.os }} + env: + PLATFORM: ${{ matrix.platform }} + ARTIFACT_NAME: boost-${{ github.event.inputs.VERSION }}-${{ matrix.platform }}-${{ matrix.toolset }}-${{ matrix.architecture }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-16.04 + platform: linux-16.04 + toolset: gcc + architecture: x64 + - os: ubuntu-18.04 + platform: linux-18.04 + toolset: gcc + architecture: x64 + - os: windows-2016 + platform: win32 + toolset: msvc-14.1 + architecture: x86_64 + - os: windows-2019 + platform: win32 + toolset: msvc-14.2 + architecture: x86_64 + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Fully cleanup the toolcache directory before testing + run: ./helpers/clean-toolcache.ps1 -ToolName "boost" + + - name: Download artifact + uses: actions/download-artifact@v2 + with: + path: ${{ runner.temp }} + + - name: Extract files + run: | + $artifactName = Get-ChildItem -Name + If ("${{ matrix.platform }}" -eq "win32") { + $assetTarPath = $artifactName.TrimEnd(".tar.gz") + 7z x $artifactName -o"$assetTarPath" -y | Out-Null + 7z x $assetTarPath -y | Out-Null + } else { + tar -xzf $artifactName + } + working-directory: ${{ runner.temp }}/${{ env.ARTIFACT_NAME }} + + - name: Apply build artifact to the local machine + run: | + if ('${{ matrix.platform }}' -eq 'win32') { powershell ./setup.ps1 } else { sh ./setup.sh } + working-directory: ${{ runner.temp }}/${{ env.ARTIFACT_NAME }} + + - name: Setup BOOST_ROOT ${{ github.event.inputs.VERSION }} + run: | + Import-Module (Join-Path $env:GITHUB_WORKSPACE "helpers" | Join-Path -ChildPath "common-helpers.psm1") -DisableNameChecking + $boostDirectory = GetToolDirectory -ToolName "boost" -Version "${{ github.event.inputs.VERSION }}" -Architecture "${{ matrix.architecture }}" + $LD_LIBRARY = Join-Path -Path $boostDirectory -ChildPath "lib" + Write-Host "BOOST_ROOT = ${boostDirectory}" + echo "::set-env name=BOOST_ROOT::${boostDirectory}" + echo "::set-env name=LD_LIBRARY_PATH::${LD_LIBRARY}" + + - name: Run tests + run: | + Install-Module Pester -Force -Scope CurrentUser + Import-Module Pester + $Platform = If ("${{ matrix.platform }}" -eq "win32") { "Windows" } else { "Nix" } + Invoke-Pester -Script ./Common.Tests.ps1 -EnableExit + Invoke-Pester -Script "./${Platform}.Tests.ps1" -EnableExit + working-directory: ./tests + + publish_release: + name: Publish release + if: github.event.inputs.PUBLISH_RELEASES == 'true' + needs: test_boost + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v2 + + - name: Publish Release ${{ env.VERSION }} + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.VERSION }}-${{ github.run_id }} + release_name: ${{ env.VERSION }} + body: | + Boost ${{ env.VERSION }} + + - name: Upload release assets + uses: actions/github-script@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const fs = require('fs'); + for (let artifactDir of fs.readdirSync('.')) { + let artifactName = fs.readdirSync(`${artifactDir}`)[0]; + console.log(`Upload ${artifactName} asset`); + github.repos.uploadReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: ${{ steps.create_release.outputs.id }}, + name: artifactName, + data: fs.readFileSync(`./${artifactDir}/${artifactName}`) + }); + } + + trigger_pr: + name: Trigger "Create Pull Request" workflow + needs: publish_release + runs-on: ubuntu-latest + steps: + - name: Trigger "Create Pull Request" workflow + uses: actions/github-script@v3 + with: + github-token: ${{ secrets.PERSONAL_TOKEN }} + script: | + github.actions.createWorkflowDispatch({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: 'create-pr.yml', + ref: 'main' + }); \ No newline at end of file diff --git a/.github/workflows/create-pr.yml b/.github/workflows/create-pr.yml new file mode 100644 index 0000000..74fe0b8 --- /dev/null +++ b/.github/workflows/create-pr.yml @@ -0,0 +1,33 @@ +name: Create Pull Request +on: + workflow_dispatch: + +defaults: + run: + shell: pwsh + +jobs: + create_pr: + name: Create Pull Request + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Create versions-manifest.json + run: | + ./helpers/packages-generation/manifest-generator.ps1 -RepositoryFullName "$env:GITHUB_REPOSITORY" ` + -GitHubAccessToken "${{secrets.GITHUB_TOKEN}}" ` + -OutputFile "./versions-manifest.json" ` + -ConfigurationFile "./config/boost-manifest-config.json" + - name: Create GitHub PR + run: | + $formattedDate = Get-Date -Format "MM/dd/yyyy" + ./helpers/github/create-pull-request.ps1 ` + -RepositoryFullName "$env:GITHUB_REPOSITORY" ` + -AccessToken "${{secrets.GITHUB_TOKEN}}" ` + -BranchName "update-versions-manifest-file" ` + -CommitMessage "Update versions-manifest" ` + -PullRequestTitle "[versions-manifest] Update for release from ${formattedDate}" ` + -PullRequestBody "Update versions-manifest.json for release from ${formattedDate}" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8765977..37fca47 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,22 +29,20 @@ Here are a few things you can do that will increase the likelihood of your pull ### Directory structure ``` -├── azure-pipelines/ -| └──templates/ +├── .github/ +| └──workflows/ ├── builders/ ├── helpers/ ├── installers/ └── tests/ └──sources/ ``` -- `azure-pipelines*` - contains global YAML definitions for build pipelines. Reusable templates for specific jobs are located in `templates` subfolder. +- `.github/workflows` - contains repository workflow files. - `builders` - contains Boost builder classes and functions. -- `helpers` - contains global helper functions and functions. +- `helpers` - contains global helper classes and functions. - `installers` - contains installation script templates. - `tests` - contains test scripts. Required tests sources are located in `sources` subfolder. -\* _We use Azure Pipelines because there are a few features that Actions is still missing, we'll move to Actions as soon as possible_. - ## Resources - [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/) diff --git a/azure-pipelines/build-boost-packages.yml b/azure-pipelines/build-boost-packages.yml deleted file mode 100644 index fb06ee1..0000000 --- a/azure-pipelines/build-boost-packages.yml +++ /dev/null @@ -1,95 +0,0 @@ -name: $(date:yyyyMMdd)$(rev:.r)-Boost-$(VERSION) -trigger: none -pr: - autoCancel: true - branches: - include: - - main - paths: - exclude: - - versions-manifest.json - -stages: -- stage: Build_Boost_Ubuntu_1604 - dependsOn: [] - variables: - VmImage: ubuntu-16.04 - Platform: linux-16.04 - Architecture: x64 - Toolset: gcc - jobs: - - template: /azure-pipelines/templates/build-job.yml - -- stage: Test_Boost_Ubuntu_1604 - condition: succeeded() - dependsOn: Build_Boost_Ubuntu_1604 - variables: - VmImage: ubuntu-16.04 - Platform: linux-16.04 - Architecture: x64 - Toolset: gcc - jobs: - - template: /azure-pipelines/templates/test-job.yml - -- stage: Build_Boost_Ubuntu_1804 - dependsOn: [] - variables: - VmImage: 'ubuntu-18.04' - Platform: linux-18.04 - Architecture: x64 - Toolset: gcc - jobs: - - template: /azure-pipelines/templates/build-job.yml - -- stage: Test_Boost_Ubuntu_1804 - condition: succeeded() - dependsOn: Build_Boost_Ubuntu_1804 - variables: - VmImage: 'ubuntu-18.04' - Platform: linux-18.04 - Architecture: x64 - Toolset: gcc - jobs: - - template: /azure-pipelines/templates/test-job.yml - -- stage: Build_Boost_msvc141 - dependsOn: [] - variables: - VmImage: 'vs2017-win2016' - Platform: win32 - Architecture: x86_64 - Toolset: msvc-14.1 - jobs: - - template: /azure-pipelines/templates/build-job.yml - -- stage: Test_Boost_msvc141 - condition: succeeded() - dependsOn: Build_Boost_msvc141 - variables: - VmImage: 'vs2017-win2016' - Platform: win32 - Architecture: x86_64 - Toolset: msvc-14.1 - jobs: - - template: /azure-pipelines/templates/test-job.yml - -- stage: Build_Boost_msvc142 - dependsOn: [] - variables: - VmImage: 'windows-2019' - Platform: win32 - Architecture: x86_64 - Toolset: msvc-14.2 - jobs: - - template: /azure-pipelines/templates/build-job.yml - -- stage: Test_Boost_msvc142 - condition: succeeded() - dependsOn: Build_Boost_msvc142 - variables: - VmImage: 'windows-2019' - Platform: win32 - Architecture: x86_64 - Toolset: msvc-14.2 - jobs: - - template: /azure-pipelines/templates/test-job.yml \ No newline at end of file diff --git a/azure-pipelines/templates/build-job.yml b/azure-pipelines/templates/build-job.yml deleted file mode 100644 index 4de7c9b..0000000 --- a/azure-pipelines/templates/build-job.yml +++ /dev/null @@ -1,20 +0,0 @@ -jobs: -- job: Build_Boost - timeoutInMinutes: 300 - pool: - name: Azure Pipelines - vmImage: $(VmImage) - steps: - - checkout: self - - task: PowerShell@2 - displayName: 'Build Boost $(Version)' - inputs: - targetType: filePath - filePath: './builders/build-boost.ps1' - arguments: '-Version $(Version) -Platform $(Platform) -Architecture $(Architecture) -Toolset $(Toolset)' - - - task: PublishPipelineArtifact@1 - displayName: 'Publish Artifact: Boost $(Version)' - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)' - artifactName: 'boost-$(Version)-$(Platform)-$(Toolset)-$(Architecture)' \ No newline at end of file diff --git a/azure-pipelines/templates/test-job.yml b/azure-pipelines/templates/test-job.yml deleted file mode 100644 index 80073f1..0000000 --- a/azure-pipelines/templates/test-job.yml +++ /dev/null @@ -1,80 +0,0 @@ -jobs: -- job: Test_Boost - pool: - name: Azure Pipelines - vmImage: $(VmImage) - steps: - - checkout: self - submodules: true - - task: PowerShell@2 - displayName: Fully cleanup the toolcache directory before testing - inputs: - targetType: filePath - filePath: helpers/clean-toolcache.ps1 - arguments: -ToolName "boost" - - - task: DownloadPipelineArtifact@2 - inputs: - source: 'current' - artifact: 'boost-$(Version)-$(Platform)-$(Toolset)-$(Architecture)' - path: $(Build.ArtifactStagingDirectory) - - - task: ExtractFiles@1 - inputs: - archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/boost-$(Version)-$(Platform)-*-$(Architecture).*' - destinationFolder: $(Build.BinariesDirectory) - cleanDestinationFolder: false - - - task: PowerShell@2 - displayName: 'Apply build artifact to the local machines' - inputs: - targetType: inline - script: | - if ("$(Platform)" -match 'win32') { powershell ./setup.ps1 } else { sh ./setup.sh } - workingDirectory: '$(Build.BinariesDirectory)' - - - task: PowerShell@2 - displayName: 'Set up BOOST_ROOT' - inputs: - TargetType: inline - script: | - $BoostToolcachePath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath "boost" - $BoostToolcacheVersionPath = Join-Path -Path $BoostToolcachePath -ChildPath "$(Version)" - $boostDirectory = Join-Path $BoostToolcacheVersionPath "$(Architecture)" - $LD_LIBRARY = Join-Path -Path $boostDirectory -ChildPath "lib" - Write-Host "BOOST_ROOT = ${boostDirectory}" - Write-Host "##vso[task.setvariable variable=BOOST_ROOT]${boostDirectory}" - Write-Host "##vso[task.setvariable variable=LD_LIBRARY_PATH]${LD_LIBRARY}" - - - task: PowerShell@2 - displayName: 'Run tests' - inputs: - TargetType: inline - script: | - Install-Module Pester -Force -Scope CurrentUser -RequiredVersion 4.10.1 - Import-Module Pester - $Platform = If ("$(Platform)" -eq "win32") { "Windows" } else { "Nix" } - $pesterParams = @( - @{ - Path="./Common.Tests.ps1"; - }, - @{ - Path="./${Platform}.Tests.ps1"; - Parameters=@{ - Version="$(Version)"; - Platform="$(Platform)" - } - } - ) - Invoke-Pester -Script $pesterParams -OutputFile "$(Build.SourcesDirectory)/tests/test_results.xml" -OutputFormat NUnitXml - workingDirectory: '$(Build.SourcesDirectory)/tests' - - - task: PublishTestResults@2 - displayName: 'Publish test results' - inputs: - testResultsFiles: '*.xml' - testResultsFormat: NUnit - searchFolder: 'tests' - failTaskOnFailedTests: true - testRunTitle: "Boost $(Version)-$(Platform)-$(Toolset)" - condition: always() diff --git a/builders/boost-builder.psm1 b/builders/boost-builder.psm1 index c5be369..0fa1248 100644 --- a/builders/boost-builder.psm1 +++ b/builders/boost-builder.psm1 @@ -16,10 +16,13 @@ class BoostBuilder { The architecture with which Boost should be built. .PARAMETER TempFolderLocation - The location of temporary files that will be used during Boost package generation. Using system BUILD_STAGINGDIRECTORY variable value. + The location of temporary files that will be used during Boost package generation. - .PARAMETER ArtifactLocation - The location of generated Boost artifact. Using system environment BUILD_BINARIESDIRECTORY variable value. + .PARAMETER WorkFolderLocation + The location of installation files. + + .PARAMETER ArtifactFolderLocation + The location of generated Boost artifact. .PARAMETER InstallationTemplatesLocation The location of installation script template. Using "installers" folder from current repository. @@ -42,8 +45,8 @@ class BoostBuilder { $this.Toolset = $toolset $this.TempFolderLocation = [IO.Path]::GetTempPath() - $this.WorkFolderLocation = $env:BUILD_BINARIESDIRECTORY - $this.ArtifactFolderLocation = $env:BUILD_STAGINGDIRECTORY + $this.WorkFolderLocation = Join-Path $env:RUNNER_TEMP "binaries" + $this.ArtifactFolderLocation = Join-Path $env:RUNNER_TEMP "artifact" $this.InstallationTemplatesLocation = Join-Path -Path $PSScriptRoot -ChildPath "../installers" } @@ -75,6 +78,10 @@ class BoostBuilder { Generates Boost artifact from downloaded binaries. #> + Write-Host "Create WorkFolderLocation and ArtifactFolderLocation folders" + New-Item -Path $this.WorkFolderLocation -ItemType "Directory" + New-Item -Path $this.ArtifactFolderLocation -ItemType "Directory" + Write-Host "Download Boost $($this.Version) source code..." $this.Download() diff --git a/helpers b/helpers index 68072be..4b0fa42 160000 --- a/helpers +++ b/helpers @@ -1 +1 @@ -Subproject commit 68072bedefb41436c6b70ddfa9adb8e631a3b6cf +Subproject commit 4b0fa42d9972d1f51dd26ca96e03987d374a1d7a diff --git a/tests/Nix.Tests.ps1 b/tests/Nix.Tests.ps1 index 0387a5e..1311098 100644 --- a/tests/Nix.Tests.ps1 +++ b/tests/Nix.Tests.ps1 @@ -1,18 +1,15 @@ -param ( - [Version] $Version, - [String] $Platform -) - Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1") -Set-Location "sources" -$env:Path="$env:Path;${env:BOOST_ROOT}\lib" +BeforeAll { + Set-Location "sources" + $env:Path="$env:Path;${env:BOOST_ROOT}\lib" + if (${env:PLATFORM} -eq "linux-16.04") { + Write-Host "Install dependencies" + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 ` + --slave /usr/bin/g++ g++ /usr/bin/g++-7 + sudo update-alternatives --config gcc +} -if ($Platform -eq "linux-16.04") { - Write-Host "Install dependencies" - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 ` - --slave /usr/bin/g++ g++ /usr/bin/g++-7 - sudo update-alternatives --config gcc } Describe "Nix Tests" { @@ -33,10 +30,10 @@ Describe "Nix Tests" { "-w", "-DBOOST_LOG_DYN_LINK", "-I", "${env:BOOST_ROOT}/include", "-L", "${env:BOOST_ROOT}/lib", "main_log.cpp", - "-l:libboost_log_setup-mt-d-x64.so.${Version}", - "-l:libboost_log-mt-d-x64.so.${Version}", - "-l:libboost_thread-mt-d-x64.so.${Version}", - "-l:libboost_filesystem-mt-d-x64.so.${Version}", + "-l:libboost_log_setup-mt-d-x64.so.${env:VERSION}", + "-l:libboost_log-mt-d-x64.so.${env:VERSION}", + "-l:libboost_thread-mt-d-x64.so.${env:VERSION}", + "-l:libboost_filesystem-mt-d-x64.so.${env:VERSION}", "-lpthread" ) @@ -49,10 +46,10 @@ Describe "Nix Tests" { "-w", "-DBOOST_LOG_DYN_LINK", "-I", "${env:BOOST_ROOT}/include", "-L", "${env:BOOST_ROOT}/lib", "main_log.cpp", - "-l:libboost_log_setup-mt-x64.so.${Version}", - "-l:libboost_log-mt-x64.so.${Version}", - "-l:libboost_thread-mt-x64.so.${Version}", - "-l:libboost_filesystem-mt-x64.so.${Version}", + "-l:libboost_log_setup-mt-x64.so.${env:VERSION}", + "-l:libboost_log-mt-x64.so.${env:VERSION}", + "-l:libboost_thread-mt-x64.so.${env:VERSION}", + "-l:libboost_filesystem-mt-x64.so.${env:VERSION}", "-lpthread" ) diff --git a/tests/Windows.Tests.ps1 b/tests/Windows.Tests.ps1 index a821868..5a43dde 100644 --- a/tests/Windows.Tests.ps1 +++ b/tests/Windows.Tests.ps1 @@ -1,17 +1,14 @@ -param ( - [Version] $Version, - [String] $Platform -) - Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1") Import-Module (Join-Path $PSScriptRoot "../helpers/win-vs-env.psm1") -Set-Location -Path "sources" +BeforeAll { + Set-Location -Path "sources" -$env:Path="$env:Path;${env:BOOST_ROOT}\lib" + $env:Path="$env:Path;${env:BOOST_ROOT}\lib" -Write-Host "Initialize VS dev environment" -Invoke-VSDevEnvironment + Write-Host "Initialize VS dev environment" + Invoke-VSDevEnvironment +} Describe "Windows Tests" { It "Run simple code" {