Skip to content

Commit c16413c

Browse files
committed
Refactor GHA build jobs into a separate action
1 parent 8360fbc commit c16413c

File tree

6 files changed

+121
-67
lines changed

6 files changed

+121
-67
lines changed

.drone/drone.bat

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
@ECHO ON
33
setlocal enabledelayedexpansion
44

5-
IF "!GHA_TARGET_BRANCH!" == "" (
6-
for /F %%i in ("!GITHUB_REF!") do @set GHA_TARGET_BRANCH=%%~nxi
5+
set TRAVIS_OS_NAME=windows
6+
7+
IF "!DRONE_BRANCH!" == "" (
78
for /F %%i in ("!GITHUB_REF!") do @set TRAVIS_BRANCH=%%~nxi
9+
) else (
10+
SET TRAVIS_BRANCH=!DRONE_BRANCH!
811
)
912

1013
if "%DRONE_JOB_BUILDTYPE%" == "boost" (
@@ -19,7 +22,7 @@ REM source ci/travis/install.sh
1922
REM The contents of install.sh below:
2023

2124
for /F %%i in ("%DRONE_REPO%") do @set SELF=%%~nxi
22-
SET BOOST_CI_TARGET_BRANCH=%DRONE_COMMIT_BRANCH%
25+
SET BOOST_CI_TARGET_BRANCH=!TRAVIS_BRANCH!
2326
SET BOOST_CI_SRC_FOLDER=%cd%
2427

2528
call ci\common_install.bat

.drone/drone.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
# (See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt)
77

88
set -e
9+
export TRAVIS_OS_NAME=linux
910
export TRAVIS_BUILD_DIR=$(pwd)
1011
export DRONE_BUILD_DIR=$(pwd)
12+
export DRONE_BRANCH=${DRONE_BRANCH:-$(echo $GITHUB_REF | cut -d/ -f3-)}
1113
export TRAVIS_BRANCH=$DRONE_BRANCH
1214
export TRAVIS_EVENT_TYPE=$DRONE_BUILD_EVENT
1315
export VCS_COMMIT_ID=$DRONE_COMMIT

.github/actions/build/action.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Run and build
2+
description: Build the project
3+
4+
inputs:
5+
comment:
6+
description: Human-readable job description
7+
required: false
8+
default: ''
9+
buildtype:
10+
description: Build type
11+
required: false
12+
default: ''
13+
cxx:
14+
description: Compiler executable to use
15+
required: false
16+
default: ''
17+
cxxstd:
18+
description: C++ standard versions to use (separated by commas)
19+
required: false
20+
default: ''
21+
toolset:
22+
description: B2 toolset to use
23+
required: false
24+
default: ''
25+
defines:
26+
description: Macro definitions to use (separated by commas)
27+
required: false
28+
default: ''
29+
variant:
30+
description: B2 build variant to use
31+
required: false
32+
default: release
33+
testflags:
34+
description: B2 test properties to set
35+
required: false
36+
default: ''
37+
b2_flags:
38+
description: Extra B2 flags to use
39+
required: false
40+
default: 'warnings=extra warnings-as-errors=on'
41+
lcov_branch_coverage:
42+
description: Whether branch coverage data should be collected and processed
43+
required: false
44+
default: ''
45+
valgrind_options:
46+
description: Valgrind options to use
47+
required: false
48+
default: ''
49+
asan:
50+
description: Use '1' to enable address sanitizer
51+
required: false
52+
default: ''
53+
ubsan:
54+
description: Use '1' to enable UB sanitizer
55+
required: false
56+
default: ''
57+
58+
runs:
59+
using: composite
60+
steps:
61+
- name: Setup environment variables
62+
shell: bash
63+
run: |
64+
echo "CXX=${{ inputs.cxx }}" >> $GITHUB_ENV
65+
echo "COMMENT=${{ inputs.comment }}" >> $GITHUB_ENV
66+
echo "LCOV_BRANCH_COVERAGE=${{ inputs.lcov_branch_coverage }}" >> $GITHUB_ENV
67+
echo "B2_CI_VERSION=1" >> $GITHUB_ENV
68+
echo "B2_CXXSTD=${{ inputs.cxxstd }}" >> $GITHUB_ENV
69+
echo "B2_TOOLSET=${{ inputs.toolset }}" >> $GITHUB_ENV
70+
echo "B2_DEFINES=${{ inputs.defines }}" >> $GITHUB_ENV
71+
echo "B2_VARIANT=${{ inputs.variant }}" >> $GITHUB_ENV
72+
echo "B2_TESTFLAGS=${{ inputs.testflags }}" >> $GITHUB_ENV
73+
echo "VALGRIND_OPTS=${{ inputs.valgrind_opts }}" >> $GITHUB_ENV
74+
echo "B2_ASAN=${{ inputs.asan }}" >> $GITHUB_ENV
75+
echo "B2_UBSAN=${{ inputs.ubsan }}" >> $GITHUB_ENV
76+
echo "B2_FLAGS=${{ inputs.b2_flags }}" >> $GITHUB_ENV
77+
echo "DRONE_BUILD_EVENT=${{ github.event_name }}" >> $GITHUB_ENV
78+
echo "DRONE_JOB_BUILDTYPE=${{ inputs.buildtype }}" >> $GITHUB_ENV
79+
echo "DRONE_COMMIT=${{ github.sha }}" >> $GITHUB_ENV
80+
echo "DRONE_BRANCH=${{ github.base_ref }}" >> $GITHUB_ENV
81+
echo "DRONE_REPO=${{ github.repository }}" >> $GITHUB_ENV
82+
83+
- name: linux
84+
if: runner.os == 'Linux'
85+
shell: bash
86+
run: . .drone/drone.sh
87+
88+
- name: windows
89+
if: runner.os == 'Windows'
90+
shell: cmd
91+
run: call .drone/drone.bat

.github/workflows/ci.yml

Lines changed: 14 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ on:
1111
- fix/**
1212
- pr/**
1313

14-
env:
15-
B2_CI_VERSION: 1
16-
B2_VARIANT: release
17-
B2_FLAGS: warnings=extra warnings-as-errors=on
18-
1914
jobs:
2015
ci:
2116
strategy:
@@ -416,55 +411,17 @@ jobs:
416411
os: ${{ matrix.llvm_os }}
417412
llvm_version: ${{ matrix.llvm_ver }}
418413

419-
- name: linux
420-
if: runner.os == 'Linux'
421-
shell: bash
422-
env:
423-
CXX: ${{ matrix.cxx }}
424-
COMMENT: ${{ matrix.comment }}
425-
LCOV_BRANCH_COVERAGE: ${{ matrix.lcov_branch_coverage }}
426-
B2_CXXSTD: ${{ matrix.b2_cxxstd }}
427-
B2_TOOLSET: ${{ matrix.b2_toolset }}
428-
B2_DEFINES: ${{ matrix.b2_defines }}
429-
B2_VARIANT: ${{ matrix.b2_variant }}
430-
B2_TESTFLAGS: ${{ matrix.b2_testflags }}
431-
VALGRIND_OPTS: ${{ matrix.valgrind_opts }}
432-
B2_ASAN: ${{ matrix.b2_asan }}
433-
B2_UBSAN: ${{ matrix.b2_ubsan }}
434-
TRAVIS_BRANCH: ${{ github.base_ref }}
435-
DRONE_BUILD_EVENT: ${{ github.event_name }}
436-
DRONE_COMMIT: ${{ github.sha }}
437-
DRONE_JOB_BUILDTYPE: ${{ matrix.buildtype }}
438-
TRAVIS_OS_NAME: "linux"
439-
run: |
440-
export DRONE_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}
441-
export DRONE_REPO=$(basename $GITHUB_REPOSITORY)
442-
. .drone/drone.sh
443-
444-
- name: windows
445-
if: runner.os == 'Windows'
446-
shell: cmd
447-
env:
448-
CXX: ${{ matrix.cxx }}
449-
SOURCES: ${{ matrix.sources }}
450-
LLVM_OS: ${{ matrix.llvm_os }}
451-
LLVM_VER: ${{ matrix.llvm_ver }}
452-
PACKAGES: ${{ matrix.packages }}
453-
COMMENT: ${{ matrix.comment }}
454-
LCOV_BRANCH_COVERAGE: ${{ matrix.lcov_branch_coverage }}
455-
B2_CXXSTD: ${{ matrix.b2_cxxstd }}
456-
B2_TOOLSET: ${{ matrix.b2_toolset }}
457-
B2_DEFINES: ${{ matrix.b2_defines }}
458-
B2_VARIANT: ${{ matrix.b2_variant }}
459-
B2_TESTFLAGS: ${{ matrix.b2_testflags }}
460-
VALGRIND_OPTS: ${{ matrix.valgrind_opts }}
461-
B2_ASAN: ${{ matrix.b2_asan }}
462-
B2_UBSAN: ${{ matrix.b2_ubsan }}
463-
GHA_TARGET_BRANCH: ${{ github.base_ref }}
464-
TRAVIS_BRANCH: ${{ github.base_ref }}
465-
DRONE_JOB_BUILDTYPE: ${{ matrix.buildtype }}
466-
DRONE_COMMIT_BRANCH: ${{ github.base_ref }}
467-
DRONE_REPO: ${{ github.repository }}
468-
TRAVIS_OS_NAME: "windows"
469-
run: |
470-
call .drone\drone.bat
414+
- uses: ./.github/actions/build
415+
with:
416+
comment: ${{ matrix.comment }}
417+
buildtype: ${{ matrix.buildtype }}
418+
cxx: ${{ matrix.cxx }}
419+
cxxstd: ${{ matrix.b2_cxxstd }}
420+
toolset: ${{ matrix.b2_toolset }}
421+
defines: ${{ matrix.b2_defines }}
422+
variant: ${{ matrix.b2_variant }}
423+
testflags: ${{ matrix.b2_testflags }}
424+
lcov_branch_coverage: ${{ matrix.lcov_branch_coverage }}
425+
valgrind_options: ${{ matrix.valgrind_opts }}
426+
asan: ${{ matrix.b2_asan }}
427+
ubsan: ${{ matrix.b2_ubsan }}

.github/workflows/run_analyze-bloat.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ jobs:
2424
with:
2525
path: 'head_ref/root'
2626
- name: Compile static lib for head ref
27+
env:
28+
DRONE_BRANCH: ${{ github.base_ref }}
29+
DRONE_REPO: ${{ github.repository }}
2730
run: |
2831
echo ${{ github.event_name }}
29-
export DRONE_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}
30-
export DRONE_REPO=$(basename $GITHUB_REPOSITORY)
3132
cd head_ref/root
3233
. .drone/drone.sh
3334
- name: Bloat analysis - absolute values
@@ -43,10 +44,11 @@ jobs:
4344
path: 'base_ref/root'
4445
- name: Compile static lib for base ref
4546
if: ${{ github.event_name == 'pull_request' }}
47+
env:
48+
DRONE_BRANCH: ${{ github.base_ref }}
49+
DRONE_REPO: ${{ github.repository }}
4650
run: |
4751
echo ${{ github.event_name }}
48-
export DRONE_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}
49-
export DRONE_REPO=$(basename $GITHUB_REPOSITORY)
5052
cd base_ref/root
5153
. .drone/drone.sh
5254
- name: Bloat analysis - diff

.github/workflows/run_fuzzer.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ jobs:
2828
CXX: clang++
2929
B2_TOOLSET: clang
3030
B2_VARIANT: release
31-
TRAVIS_BRANCH: ${{ github.base_ref }}
3231
TRAVIS_OS_NAME: "linux"
3332
B2_TARGETS: libs/json/fuzzing//run
3433
DRONE_BUILD_EVENT: ${{ github.event_name }}
3534
DRONE_COMMIT: ${{ github.sha }}
35+
DRONE_BRANCH: ${{ github.base_ref }}
36+
DRONE_REPO: ${{ github.repository }}
3637
DRONE_JOB_BUILDTYPE: 'boost'
3738
run: |
38-
export DRONE_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}
39-
export DRONE_REPO=$(basename $GITHUB_REPOSITORY)
4039
cd head
4140
. .drone/drone.sh
4241
- name: Pack the corpus

0 commit comments

Comments
 (0)