|
1 | 1 | name: "Main workflow" |
2 | 2 | on: push |
| 3 | +permissions: |
| 4 | + contents: read |
3 | 5 |
|
4 | 6 | jobs: |
5 | 7 | configure: |
6 | | - runs-on: ubuntu-latest |
| 8 | + runs-on: ${{ github.repository_owner == 'zondax' && 'zondax-runners' || 'ubuntu-latest' }} |
7 | 9 | outputs: |
8 | 10 | uid_gid: ${{ steps.get-user.outputs.uid_gid }} |
9 | 11 | steps: |
10 | 12 | - id: get-user |
11 | 13 | run: echo "uid_gid=$(id -u):$(id -g)" >> $GITHUB_OUTPUT |
12 | 14 |
|
| 15 | + setup: |
| 16 | + runs-on: ${{ github.repository_owner == 'zondax' && 'zondax-runners' || 'ubuntu-latest' }} |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + submodules: true |
| 22 | + - name: Cache APT packages |
| 23 | + uses: actions/cache@v4 |
| 24 | + with: |
| 25 | + path: /var/cache/apt/archives |
| 26 | + key: ${{ runner.os }}-apt-${{ hashFiles('**/main.yml') }} |
| 27 | + restore-keys: | |
| 28 | + ${{ runner.os }}-apt- |
| 29 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + sudo apt-get update |
| 32 | + sudo apt-get install -y curl protobuf-compiler build-essential git wget unzip python3 python3-pip \ |
| 33 | + libssl-dev libffi-dev libreadline-dev zlib1g-dev libbz2-dev libsqlite3-dev libncurses5-dev \ |
| 34 | + libgdbm-dev libnss3-dev liblzma-dev libxml2-dev libxmlsec1-dev libffi-dev libyaml-dev |
| 35 | + - name: Cache CMake installation |
| 36 | + uses: actions/cache@v4 |
| 37 | + id: cmake-cache |
| 38 | + with: |
| 39 | + path: /opt/cmake |
| 40 | + key: cmake-3.28.0-${{ runner.os }} |
| 41 | + - name: Install CMake 3.28 |
| 42 | + if: steps.cmake-cache.outputs.cache-hit != 'true' |
| 43 | + run: | |
| 44 | + wget https://github.com/Kitware/CMake/releases/download/v3.28.0/cmake-3.28.0-linux-x86_64.sh |
| 45 | + sudo mkdir -p /opt/cmake |
| 46 | + sudo sh cmake-3.28.0-linux-x86_64.sh --skip-license --prefix=/opt/cmake |
| 47 | + - name: Setup CMake symlinks |
| 48 | + run: | |
| 49 | + sudo ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake |
| 50 | + sudo ln -sf /opt/cmake/bin/ctest /usr/local/bin/ctest |
| 51 | + - name: Verify CMake version |
| 52 | + run: cmake --version |
| 53 | + |
13 | 54 | build: |
14 | | - runs-on: ubuntu-latest |
| 55 | + runs-on: ${{ github.repository_owner == 'zondax' && 'zondax-runners' || 'ubuntu-latest' }} |
| 56 | + needs: setup |
15 | 57 | steps: |
16 | 58 | - name: Checkout |
17 | 59 | uses: actions/checkout@v4 |
18 | 60 | with: |
19 | 61 | submodules: true |
| 62 | + - name: Restore APT cache |
| 63 | + uses: actions/cache@v4 |
| 64 | + with: |
| 65 | + path: /var/cache/apt/archives |
| 66 | + key: ${{ runner.os }}-apt-${{ hashFiles('**/main.yml') }} |
| 67 | + restore-keys: | |
| 68 | + ${{ runner.os }}-apt- |
| 69 | + - name: Install dependencies |
| 70 | + run: | |
| 71 | + sudo apt-get update |
| 72 | + sudo apt-get install -y curl protobuf-compiler build-essential git wget unzip python3 python3-pip \ |
| 73 | + libssl-dev libffi-dev libreadline-dev zlib1g-dev libbz2-dev libsqlite3-dev libncurses5-dev \ |
| 74 | + libgdbm-dev libnss3-dev liblzma-dev libxml2-dev libxmlsec1-dev libffi-dev libyaml-dev |
| 75 | + - name: Restore CMake cache |
| 76 | + uses: actions/cache@v4 |
| 77 | + id: cmake-cache-restore |
| 78 | + with: |
| 79 | + path: /opt/cmake |
| 80 | + key: cmake-3.28.0-${{ runner.os }} |
| 81 | + - name: Install CMake 3.28 (if cache miss) |
| 82 | + if: steps.cmake-cache-restore.outputs.cache-hit != 'true' |
| 83 | + run: | |
| 84 | + wget https://github.com/Kitware/CMake/releases/download/v3.28.0/cmake-3.28.0-linux-x86_64.sh |
| 85 | + sudo mkdir -p /opt/cmake |
| 86 | + sudo sh cmake-3.28.0-linux-x86_64.sh --skip-license --prefix=/opt/cmake |
| 87 | + - name: Setup CMake symlinks |
| 88 | + run: | |
| 89 | + sudo ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake |
| 90 | + sudo ln -sf /opt/cmake/bin/ctest /usr/local/bin/ctest |
| 91 | + - name: Verify CMake version |
| 92 | + run: cmake --version |
20 | 93 | - run: make build |
21 | 94 | - name: Run C++ tests |
22 | 95 | run: make test |
23 | 96 |
|
24 | 97 | check_version: |
25 | | - runs-on: ubuntu-latest |
| 98 | + runs-on: ${{ github.repository_owner == 'zondax' && 'zondax-runners' || 'ubuntu-latest' }} |
26 | 99 | outputs: |
27 | 100 | version: ${{ steps.get-version.outputs.version }} |
28 | 101 | exists: ${{ steps.get-version.outputs.exists }} |
|
48 | 121 | run: exit 1 |
49 | 122 |
|
50 | 123 | tag: |
51 | | - runs-on: ubuntu-latest |
| 124 | + runs-on: ${{ github.repository_owner == 'zondax' && 'zondax-runners' || 'ubuntu-latest' }} |
| 125 | + permissions: |
| 126 | + contents: write |
52 | 127 | needs: |
53 | 128 | - build |
54 | 129 | - check_version |
|
0 commit comments