3a27fd2d9fef42b8ba2a318db502cd8018cd3b1f
[platform/upstream/nnstreamer.git] / .github / workflows / pdebuild.yml
1 name: Build and unit test/ Pdebuild Ubuntu 22.04
2
3 # ${{ github.event.pull_request.commits }} : # commits in this PR
4 # - changed_file_list in GITHUB_ENV: the list of files updated in this pull-request.
5
6 ## @todo apply "cache" to pdebuilder cache, or create docker images ready for pdebuild
7
8 on:
9   pull_request:
10     branches: [ main ]
11
12 jobs:
13   build:
14
15     runs-on: ${{ matrix.os }}
16     strategy:
17       matrix:
18         #os: [ ubuntu-20.04, ubuntu-22.04 ]
19         ## ppa/nnstreamer's ubuntu 20.04 has gpgv error:
20         # E: Release signed by unknown key (key id CADA0F77901522B3)
21         #    The specified keyring /usr/share/keyrings/ubuntu-archive-keyring.gpg may be incorrect or out of date.
22         #    You can find the latest Debian release key at https://ftp-master.debian.org/keys.html
23         # E: debootstrap failed
24         # E: Tail of debootstrap.log:
25         # amd64: ok
26         # 2024-01-24 15:01:58 URL:http://ppa.launchpad.net/nnstreamer/ppa/ubuntu/dists/focal/InRelease [18035/18035] -> "/var/cache/pbuilder/build/10399/var/lib/apt/lists/partial/ppa.launchpad.net_nnstreamer_ppa_ubuntu_dists_focal_InRelease" [1]
27         # gpgv: Signature made Wed Jan 24 09:12:55 2024 UTC
28         # gpgv:                using RSA key 373A37D40E480F96524A4027CADA0F77901522B3
29         # gpgv: Can't check signature: No public key
30         # E: End of debootstrap.log
31         # W: Aborting with an error
32         os: [ ubuntu-22.04 ]
33         arch: [ amd64, arm64 ]
34         include:
35           - distroname: jammy
36             os: ubuntu-22.04
37         #  - distroname: focal
38         #    os: ubuntu-20.04
39
40     steps:
41     - uses: actions/checkout@v4
42       with:
43         ref: ${{ github.event.pull_request.head.sha }}
44         fetch-depth: -${{ github.event.pull_request.commits }}
45     - name: Check if rebuild required
46       ## @todo This should become a reusable workflow.
47       run: |
48         tmpfile=$(mktemp)
49         git show --pretty="format:" --name-only --diff-filter=AMRC ${{ github.event.pull_request.head.sha}} -${{ github.event.pull_request.commits }} | sort | uniq | awk NF > ${tmpfile}
50         echo "changed_file_list=${tmpfile}" >> "$GITHUB_ENV"
51         rebuild=`bash .github/workflows/check_if_rebuild_requires.sh ${tmpfile} debian | grep "REBUILD=YES" | wc -l`
52         echo "Rebuild required: ${rebuild}"
53         echo "rebuild=${rebuild}" >> "$GITHUB_ENV"
54     - uses: actions/setup-python@v1
55     - name: make cache key
56       if: env.rebuild == '1'
57       id: make-key
58       run: echo "cache_key=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
59       shell: bash
60     - name: cache pbuilder cache
61       id: cache-pbuilder
62       if: env.rebuild == '1'
63       uses: actions/cache@v3
64       with:
65         path: /var/cache/pbuilder
66         key: ${{ steps.make-key.outputs.cache_key }}
67     - name: prepare pdebuild
68       if: env.rebuild == '1'
69       run: |
70         echo "Installing build tools"
71         sudo add-apt-repository ppa:nnstreamer/ppa
72         echo "::group::apt-get update && apt-get install"
73         sudo apt-get update && sudo apt-get install -y pbuilder debootstrap curl ubuntu-dev-tools qemu-user-static debian-archive-keyring ubuntu-keyring debhelper
74         echo "::endgroup::"
75         echo "DISTRIBUTION=${{ matrix.distroname }}" > ~/.pbuilderrc
76         echo "OTHERMIRROR=\"deb [trusted=yes] http://archive.ubuntu.com/ubuntu ${{ matrix.distroname }}-backports universe |deb [trusted=yes] http://ppa.launchpad.net/nnstreamer/ppa/ubuntu ${{ matrix.distroname }} main\"" >> ~/.pbuilderrc
77         cat ~/.pbuilderrc
78         sudo mkdir -p /root/
79         sudo ln -s ~/.pbuilderrc /root/
80         echo "=== pbuilder create"
81         echo "::group::pbuilder create --allow-untrusted"
82         sudo pbuilder create --allow-untrusted
83         echo "::endgroup::"
84         echo "=== pbuilder update"
85         echo "::group::pbuilder update --distribution ${{ matrix.distroname }}"
86         sudo pbuilder update --distribution ${{ matrix.distroname }}
87         echo "::endgroup"
88         echo "::group::pbuilder update"
89         sudo pbuilder update
90         echo "::endgroup"
91     - name: run pdebuild
92       if: env.rebuild == '1'
93       run: |
94         pdebuild --architecture ${{ matrix.arch }} -- --distribution ${{ matrix.distroname }}