From 2647e8c5b7bd2494176358525089fbb8c9d630be Mon Sep 17 00:00:00 2001 From: Nikita Bykov <49442273+nikita-bykov@users.noreply.github.com> Date: Tue, 1 Sep 2020 12:04:22 +0300 Subject: [PATCH] Test branch (#1) * migrate ci * updated submodule * update * update Co-authored-by: Nikita Bykov --- .github/workflows/build-boost-packages.yml | 160 +++++++++++++++++++++ .github/workflows/create-pr.yml | 33 +++++ builders/boost-builder.psm1 | 17 ++- helpers | 2 +- 4 files changed, 206 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/build-boost-packages.yml create mode 100644 .github/workflows/create-pr.yml diff --git a/.github/workflows/build-boost-packages.yml b/.github/workflows/build-boost-packages.yml new file mode 100644 index 0000000..6d2c9e1 --- /dev/null +++ b/.github/workflows/build-boost-packages.yml @@ -0,0 +1,160 @@ +name: Generate Boost package +on: + push: + workflow_dispatch: + inputs: + VERSION: + description: 'Boost version to build and upload' + required: true + default: '1.15.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.platform }}] + runs-on: ubuntu-latest + env: + ARTIFACT_NAME: Boost-${{ github.event.inputs.VERSION }}-${{ matrix.platform }}-x64 + strategy: + fail-fast: false + matrix: + platform: [linux, darwin, 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 }} + - 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.platform }}] + # needs: build_boost + # runs-on: ${{ matrix.os }} + # env: + # ARTIFACT_NAME: boost-${{ github.event.inputs.VERSION }}-${{ matrix.platform }}-x64 + # strategy: + # fail-fast: false + # matrix: + # include: + # - os: ubuntu-latest + # platform: linux + # - os: macos-latest + # platform: darwin + # - os: windows-latest + # platform: win32 + # 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: | + # if ('${{ matrix.platform }}' -eq 'win32') { + # $artifactName = "${{ env.ARTIFACT_NAME }}.zip" + # 7z.exe x "$artifactName" -y | Out-Null + # } else { + # $artifactName = "${{ env.ARTIFACT_NAME }}.tar.gz" + # 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 ${{ env.VERSION }} + # uses: actions/setup-boost@v2.1.1 + # with: + # boost-version: ${{ env.VERSION }} + + # - name: Wait for the logs + # run: | + # Write-Host "Fake step that do nothing" + # Write-Host "We need it because log of previous step 'Setup Boost' is not available here yet." + # Write-Host "In testing step (Boost.Tests.ps1) we analyze build log of 'Setup Boost' task" + # Write-Host "to determine if Boost.js version was consumed from cache and was downloaded" + # for ($i = 0; $i -lt 200; $i++) { Get-Random } + # - name: Run tests + # run: | + # Install-Module Pester -Force -Scope CurrentUser + # Import-Module Pester + # Invoke-Pester -Script ./Boost.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' + }); diff --git a/.github/workflows/create-pr.yml b/.github/workflows/create-pr.yml new file mode 100644 index 0000000..a265ef1 --- /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/go-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/builders/boost-builder.psm1 b/builders/boost-builder.psm1 index c5be369..d9e94df 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 Go 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 Go 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..f8f76ca 160000 --- a/helpers +++ b/helpers @@ -1 +1 @@ -Subproject commit 68072bedefb41436c6b70ddfa9adb8e631a3b6cf +Subproject commit f8f76caff1878d249468db3d55f045c0b707493b