-
Notifications
You must be signed in to change notification settings - Fork 87
121 lines (107 loc) · 4.9 KB
/
package-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
name: Package Build
on:
pull_request_target:
merge_group:
types: [checks_requested]
jobs:
ccache-build:
name: CCache Build
runs-on: ubuntu-latest
container:
image: ghcr.io/rpm-software-management/dnf-ci-host
strategy:
fail-fast: false # don't fail all matrix jobs if one of them fails
matrix:
compiler: [gcc, clang] # gcc is the default
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure CC CXX env variables
id: configure_compiler
run: |
if [[ "${{matrix.compiler}}" -eq "clang" ]]; then
echo "cxx=/usr/lib64/ccache/clang++" >> "$GITHUB_OUTPUT"
echo "cc=/usr/lib64/ccache/clang" >> "$GITHUB_OUTPUT"
else
echo "cxx=/usr/lib64/ccache/g++" >> "$GITHUB_OUTPUT"
echo "cc=/usr/lib64/ccache/gcc" >> "$GITHUB_OUTPUT"
fi
# make sure that for every build the GitHub Actions cache key is unique
- name: Prepare CCache timestamp
id: ccache_cache_timestamp
run:
echo "timestamp=$(date +%Y-%m-%d-%H:%M:%S)-UTC" >> "$GITHUB_OUTPUT"
- name: Cache CCache files
uses: actions/cache@v3
with:
path: ~/.cache/ccache
# cache is saved with this hierarchy
# dnf5-ccache-gcc-pr-main-111-2023-01-01-00:00:00-UTC
# -clang-pr-main-111-2023-01-01-00:00:00-UTC
key: ${{ github.event.repository.name }}-ccache-${{ matrix.compiler }}-pr-${{ github.base_ref }}-${{ github.event.number }}-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
# we want to match the latest cache prioritizing the same PR (e.g.
# 111), then the same branch (e.g. main), and, in all cases, we want
# to match the project-compiler (gcc,clang) match by date is not
# needed since caches are always matched by date.
#
# Example: dnf5-ccache-clang-pr-devel-111-2023-01-01-00:00:00-UTC will
# try to fetch cache from the same pr, 111 against devel. if no pr is
# found it will try to fetch any pr against devel branch.
restore-keys: |
${{ github.event.repository.name }}-ccache-${{ matrix.compiler }}-pr-${{ github.base_ref }}-${{ github.event.number }}-
${{ github.event.repository.name }}-ccache-${{ matrix.compiler }}-pr-${{ github.base_ref }}-
- name: Zero CCache statistics
run: ccache -z
- name: Configure DNF5 with CMake
run: CXX=${{ steps.configure_compiler.outputs.cxx }} CC=${{ steps.configure_compiler.outputs.cc }} cmake -S . -B build
- name: Build DNF5
id: ccache-build
run: cmake --build build
- name: Display CCache statistics
run: ccache -s
rpm-gitoverlay-build:
name: Git Overlay Build
needs: [ ccache-build ]
# If any of the jobs listed in needs return "failure" then run this job
if: ${{ always() && contains(needs.*.result, 'failure') }}
runs-on: ubuntu-latest
container: ghcr.io/rpm-software-management/dnf-ci-host
strategy:
fail-fast: false # don't fail all matrix jobs if one of them fails
matrix:
compiler: ['', clang] # gcc is the default
steps:
- name: Check out ci-dnf-stack
uses: actions/checkout@v2
with:
repository: rpm-software-management/ci-dnf-stack
- name: Setup CI
id: setup-ci
uses: ./.github/actions/setup-ci
with:
copr-user: ${{secrets.COPR_USER}}
copr-api-token: ${{secrets.COPR_API_TOKEN}}
- name: Check out sources
uses: actions/checkout@v2
with:
path: gits/${{github.event.repository.name}}
ref: ${{github.event.pull_request.head.sha}} # check out the PR HEAD
fetch-depth: 0
- name: Rebase the pull request on target branch
run: |
pushd gits/${{github.event.repository.name}}
git config user.name github-actions
git config user.email [email protected]
echo "Rebasing \"`git log --oneline -1`\" on ${{github.event.pull_request.base.ref}}: \"`git log --oneline -1 origin/${{github.event.pull_request.base.ref}}`\""
git rebase origin/${{github.event.pull_request.base.ref}}
popd
- name: Build in Copr
run: |
CHROOTS="fedora-37-x86_64, fedora-38-x86_64, fedora-rawhide-x86_64"
PROJECT_NAME="CI-libdnf5-pr${{github.event.pull_request.number}}"
if [[ -n "${{matrix.compiler}}" ]]; then
PROJECT_NAME+="-${{matrix.compiler}}"
fi
rpm-gitoverlay --gitdir=gits build-overlay -s overlays/dnf5-unstable rpm --with "${{matrix.compiler}}" copr --owner "${{steps.setup-ci.outputs.copr-user}}" --project "$PROJECT_NAME" --chroots "$CHROOTS" --delete-project-after-days=7 --additional-repos="copr://rpmsoftwaremanagement/dnf-nightly copr://rpmsoftwaremanagement/dnf5-unstable"