Skip to content

Commit

Permalink
#312 Reduce code duplication in GHAs
Browse files Browse the repository at this point in the history
WIP
  • Loading branch information
cmannett85 committed Mar 29, 2023
1 parent 685119d commit b167d8e
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 152 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/bootstrap_vcpkg/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Bootstrap vcpkg and Configure NuGet
description: Bootsraps vcpkg with disabled metrics, and configures NuGet as a bianry cache

inputs:
token:
description: "GitHub password token"
required: true

runs:
using: "composite"
steps:
- name: Configure env vars
shell: bash
run: |
echo "NUGET_SOURCE_URL=\"https://nuget.pkg.github.com/cmannett85/index.json\"" >> $GITHUB_ENV
echo "VCPKG_BINARY_SOURCES=\'clear;nuget,vcpkg-cache,readwrite\'" >> $GITHUB_ENV
- name: Bootstrap vcpkg to build the NuGet client on Linux and MacOS
if: runner.os != 'Windows'
shell: bash
run: |
cd ${{ github.workspace }}
./external/vcpkg/bootstrap-vcpkg.sh -disableMetrics
- name: Bootstrap vcpkg to build the NuGet client on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
cd ${{ github.workspace }}
./external/vcpkg/bootstrap-vcpkg.bat -disableMetrics
- name: Configure NuGet client on Linux and MacOS
if: runner.os != 'Windows'
shell: bash
run: |
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
sources add \
-source ${{ env.NUGET_SOURCE_URL }} \
-storepasswordincleartext \
-name "vcpkg-cache" \
-username "cmannett85" \
-password "${{ inputs.token }}"
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
setapikey "${{ inputs.token }}" \
-source ${{ env.NUGET_SOURCE_URL }}
- name: Configure NuGet client on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
[array] $output = ./external/vcpkg/vcpkg.exe fetch nuget
& $output[-1] sources add -source ${{ env.NUGET_SOURCE_URL }} -storepasswordincleartext -name "vcpkg-cache" -username "cmannett85" -password "${{ inputs.token }}"
& $output[-1] setapikey "${{ inputs.token }}" -source ${{ env.NUGET_SOURCE_URL }}
21 changes: 3 additions & 18 deletions .github/workflows/docs_pusher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ on:

env:
SKIP_COVERAGE_UPDATE: 1
NUGET_SOURCE_URL: "https://nuget.pkg.github.com/cmannett85/index.json"
VCPKG_BINARY_SOURCES: 'clear;nuget,vcpkg-cache,readwrite'
BUILD_DIR: ${{ github.workspace }}/build

jobs:
Expand All @@ -26,22 +24,9 @@ jobs:
sudo apt update
sudo apt install lcov ninja-build doxygen graphviz
- name: Bootstrap vcpkg to build the NuGet client
run: |
./external/vcpkg/bootstrap-vcpkg.sh -disableMetrics
- name: Configure NuGet client
run: |
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
sources add \
-source ${{ env.NUGET_SOURCE_URL }} \
-storepasswordincleartext \
-name "vcpkg-cache" \
-username "cmannett85" \
-password "${{ secrets.GITHUB_TOKEN }}"
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
setapikey "${{ secrets.GITHUB_TOKEN }}" \
-source ${{ env.NUGET_SOURCE_URL }}
- uses: ./.github/workflows/bootstrap_vcpkg
with:
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Generate API documentation and build Unit Tests
timeout-minutes: 30
Expand Down
109 changes: 18 additions & 91 deletions .github/workflows/merge_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:

env:
SKIP_COVERAGE_UPDATE: 1
NUGET_SOURCE_URL: "https://nuget.pkg.github.com/cmannett85/index.json"
VCPKG_BINARY_SOURCES: 'clear;nuget,vcpkg-cache,readwrite'
BUILD_DIR: ${{ github.workspace }}/build
INSTALL_DIR: ${{ github.workspace }}/install
PACKAGE_BUILD_DIR: ${{ github.workspace }}/package_build
Expand All @@ -29,22 +27,9 @@ jobs:
sudo apt update
sudo apt install ninja-build
- name: Bootstrap vcpkg to build the NuGet client
run: |
./external/vcpkg/bootstrap-vcpkg.sh -disableMetrics
- name: Configure NuGet client
run: |
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
sources add \
-source ${{ env.NUGET_SOURCE_URL }} \
-storepasswordincleartext \
-name "vcpkg-cache" \
-username "cmannett85" \
-password "${{ secrets.GITHUB_TOKEN }}"
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
setapikey "${{ secrets.GITHUB_TOKEN }}" \
-source ${{ env.NUGET_SOURCE_URL }}
- uses: ./.github/workflows/bootstrap_vcpkg
with:
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Build
timeout-minutes: 30
Expand Down Expand Up @@ -73,22 +58,9 @@ jobs:
sudo apt update
sudo apt install ninja-build
- name: Bootstrap vcpkg to build the NuGet client
run: |
./external/vcpkg/bootstrap-vcpkg.sh -disableMetrics
- name: Configure NuGet client
run: |
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
sources add \
-source ${{ env.NUGET_SOURCE_URL }} \
-storepasswordincleartext \
-name "vcpkg-cache" \
-username "cmannett85" \
-password "${{ secrets.GITHUB_TOKEN }}"
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
setapikey "${{ secrets.GITHUB_TOKEN }}" \
-source ${{ env.NUGET_SOURCE_URL }}
- uses: ./.github/workflows/bootstrap_vcpkg
with:
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Build
timeout-minutes: 30
Expand Down Expand Up @@ -117,22 +89,9 @@ jobs:
sudo apt update
sudo apt install ninja-build g++-multilib
- name: Bootstrap vcpkg to build the NuGet client
run: |
./external/vcpkg/bootstrap-vcpkg.sh -disableMetrics
- name: Configure NuGet client
run: |
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
sources add \
-source ${{ env.NUGET_SOURCE_URL }} \
-storepasswordincleartext \
-name "vcpkg-cache" \
-username "cmannett85" \
-password "${{ secrets.GITHUB_TOKEN }}"
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
setapikey "${{ secrets.GITHUB_TOKEN }}" \
-source ${{ env.NUGET_SOURCE_URL }}
- uses: ./.github/workflows/bootstrap_vcpkg
with:
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Build
timeout-minutes: 30
Expand Down Expand Up @@ -161,15 +120,9 @@ jobs:
with:
submodules: true

- name: Bootstrap vcpkg to build the NuGet client
run: |
./external/vcpkg/bootstrap-vcpkg.bat -disableMetrics
- name: Configure NuGet client
run: |
[array] $output = ./external/vcpkg/vcpkg.exe fetch nuget
& $output[-1] sources add -source ${{ env.NUGET_SOURCE_URL }} -storepasswordincleartext -name "vcpkg-cache" -username "cmannett85" -password "${{ secrets.GITHUB_TOKEN }}"
& $output[-1] setapikey "${{ secrets.GITHUB_TOKEN }}" -source ${{ env.NUGET_SOURCE_URL }}
- uses: ./.github/workflows/bootstrap_vcpkg
with:
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Build
timeout-minutes: 30
Expand Down Expand Up @@ -220,22 +173,9 @@ jobs:
run: |
brew install clang-format
- name: Bootstrap vcpkg to build the NuGet client
run: |
./external/vcpkg/bootstrap-vcpkg.sh -disableMetrics
- name: Configure NuGet client
run: |
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
sources add \
-source ${{ env.NUGET_SOURCE_URL }} \
-storepasswordincleartext \
-name "vcpkg-cache" \
-username "cmannett85" \
-password "${{ secrets.GITHUB_TOKEN }}"
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
setapikey "${{ secrets.GITHUB_TOKEN }}" \
-source ${{ env.NUGET_SOURCE_URL }}
- uses: ./.github/workflows/bootstrap_vcpkg
with:
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Build
timeout-minutes: 30
Expand Down Expand Up @@ -284,22 +224,9 @@ jobs:
sudo apt update
sudo apt install ninja-build
- name: Bootstrap vcpkg to build the NuGet client
run: |
./external/vcpkg/bootstrap-vcpkg.sh -disableMetrics
- name: Configure NuGet client
run: |
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
sources add \
-source ${{ env.NUGET_SOURCE_URL }} \
-storepasswordincleartext \
-name "vcpkg-cache" \
-username "cmannett85" \
-password "${{ secrets.GITHUB_TOKEN }}"
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
setapikey "${{ secrets.GITHUB_TOKEN }}" \
-source ${{ env.NUGET_SOURCE_URL }}
- uses: ./.github/workflows/bootstrap_vcpkg
with:
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Build
run: |
Expand Down
52 changes: 9 additions & 43 deletions .github/workflows/pr_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:

env:
SKIP_COVERAGE_UPDATE: 0
NUGET_SOURCE_URL: "https://nuget.pkg.github.com/cmannett85/index.json"
VCPKG_BINARY_SOURCES: 'clear;nuget,vcpkg-cache,readwrite'
BUILD_DIR: ${{ github.workspace }}/build
INSTALL_DIR: ${{ github.workspace }}/install
PACKAGE_BUILD_DIR: ${{ github.workspace }}/package_build
Expand Down Expand Up @@ -48,22 +46,9 @@ jobs:
sudo apt update
sudo apt install valgrind lcov ninja-build
- name: Bootstrap vcpkg to build the NuGet client
run: |
./external/vcpkg/bootstrap-vcpkg.sh -disableMetrics
- name: Configure NuGet client
run: |
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
sources add \
-source ${{ env.NUGET_SOURCE_URL }} \
-storepasswordincleartext \
-name "vcpkg-cache" \
-username "cmannett85" \
-password "${{ secrets.GITHUB_TOKEN }}"
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
setapikey "${{ secrets.GITHUB_TOKEN }}" \
-source ${{ env.NUGET_SOURCE_URL }}
- uses: ./.github/workflows/bootstrap_vcpkg
with:
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Build
timeout-minutes: 30
Expand Down Expand Up @@ -130,22 +115,9 @@ jobs:
sudo apt update
sudo apt install ninja-build
- name: Bootstrap vcpkg to build the NuGet client
run: |
./external/vcpkg/bootstrap-vcpkg.sh -disableMetrics
- name: Configure NuGet client
run: |
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
sources add \
-source ${{ env.NUGET_SOURCE_URL }} \
-storepasswordincleartext \
-name "vcpkg-cache" \
-username "cmannett85" \
-password "${{ secrets.GITHUB_TOKEN }}"
mono `./external/vcpkg/vcpkg fetch nuget | tail -n 1` \
setapikey "${{ secrets.GITHUB_TOKEN }}" \
-source ${{ env.NUGET_SOURCE_URL }}
- uses: ./.github/workflows/bootstrap_vcpkg
with:
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Build
timeout-minutes: 30
Expand Down Expand Up @@ -175,15 +147,9 @@ jobs:
with:
submodules: true

- name: Bootstrap vcpkg to build the NuGet client
run: |
./external/vcpkg/bootstrap-vcpkg.bat -disableMetrics
- name: Configure NuGet client
run: |
[array] $output = ./external/vcpkg/vcpkg.exe fetch nuget
& $output[-1] sources add -source ${{ env.NUGET_SOURCE_URL }} -storepasswordincleartext -name "vcpkg-cache" -username "cmannett85" -password "${{ secrets.GITHUB_TOKEN }}"
& $output[-1] setapikey "${{ secrets.GITHUB_TOKEN }}" -source ${{ env.NUGET_SOURCE_URL }}
- uses: ./.github/workflows/bootstrap_vcpkg
with:
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Build
timeout-minutes: 30
Expand Down

0 comments on commit b167d8e

Please sign in to comment.