From cab62c16125ad918601dbfa021549fc752a5c982 Mon Sep 17 00:00:00 2001 From: David Hummel Date: Fri, 30 Jul 2021 00:06:32 -0700 Subject: [PATCH] Reduce redundant CI configuration by using local actions --- .github/actions/apt/install/action.yml | 11 +++ .github/actions/apt/update/action.yml | 6 ++ .../actions/build-archive/create/action.yml | 11 +++ .../actions/build-archive/extract/action.yml | 10 +++ .github/workflows/github-actions.yml | 76 ++++++++++--------- 5 files changed, 79 insertions(+), 35 deletions(-) create mode 100644 .github/actions/apt/install/action.yml create mode 100644 .github/actions/apt/update/action.yml create mode 100644 .github/actions/build-archive/create/action.yml create mode 100644 .github/actions/build-archive/extract/action.yml diff --git a/.github/actions/apt/install/action.yml b/.github/actions/apt/install/action.yml new file mode 100644 index 0000000..2d94483 --- /dev/null +++ b/.github/actions/apt/install/action.yml @@ -0,0 +1,11 @@ +--- +inputs: + packages: + description: List of packages to install + required: true + +runs: + using: composite + steps: + - run: sudo apt --yes install ${{ inputs.packages }} + shell: bash diff --git a/.github/actions/apt/update/action.yml b/.github/actions/apt/update/action.yml new file mode 100644 index 0000000..d60e26d --- /dev/null +++ b/.github/actions/apt/update/action.yml @@ -0,0 +1,6 @@ +--- +runs: + using: composite + steps: + - run: sudo apt --yes update + shell: bash diff --git a/.github/actions/build-archive/create/action.yml b/.github/actions/build-archive/create/action.yml new file mode 100644 index 0000000..23bb117 --- /dev/null +++ b/.github/actions/build-archive/create/action.yml @@ -0,0 +1,11 @@ +--- +runs: + using: composite + steps: + - name: Create build archive + run: | + tar --verbose --create --zstd \ + --file=/tmp/workspace.tar.zst \ + * + shell: bash + working-directory: ${{ github.workspace }}/.. diff --git a/.github/actions/build-archive/extract/action.yml b/.github/actions/build-archive/extract/action.yml new file mode 100644 index 0000000..da426f8 --- /dev/null +++ b/.github/actions/build-archive/extract/action.yml @@ -0,0 +1,10 @@ +--- +runs: + using: composite + steps: + - name: Extract build archive + run: | + tar --verbose --extract --zstd \ + --file=/tmp/workspace.tar.zst + shell: bash + working-directory: ${{ github.workspace }}/.. diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index bc4a441..628a396 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -8,6 +8,15 @@ on: - master - develop +env: + build-dependencies: >- + apache2-dev + libcairo2-dev + libcurl4-gnutls-dev + libglib2.0-dev + libiniparser-dev + libmapnik-dev + jobs: lint-astyle: name: Lint code with `astyle` @@ -16,9 +25,11 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - name: Update installed packages - run: sudo apt --yes update + uses: ./.github/actions/apt/update - name: Install `astyle` - run: sudo apt --yes install astyle + uses: ./.github/actions/apt/install + with: + packages: astyle - name: Run `astyle` run: | astyle \ @@ -46,12 +57,11 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - name: Update installed packages - run: sudo apt --yes update + uses: ./.github/actions/apt/update - name: Install build dependencies - run: | - sudo apt --yes install \ - apache2-dev libcairo2-dev libcurl4-gnutls-dev libglib2.0-dev \ - libiniparser-dev libmapnik-dev + uses: ./.github/actions/apt/install + with: + packages: ${{ env.build-dependencies }} - name: Run `./autogen.sh` run: ./autogen.sh - name: Run `./configure` @@ -59,14 +69,12 @@ jobs: - name: Run `make` run: make - name: Create build archive - run: | - tar --verbose --create --file=/tmp/workspace.tar \ - ${{ github.workspace }} - - name: Upload build artifacts + uses: ./.github/actions/build-archive/create + - name: Upload build archive uses: actions/upload-artifact@v2 with: - name: build - path: /tmp/workspace.tar + name: build-archive + path: /tmp/workspace.tar.zst test-make-test: name: Test with `make test` @@ -75,20 +83,21 @@ jobs: - build - lint-astyle steps: + - name: Checkout code + uses: actions/checkout@v2 - name: Update installed packages - run: sudo apt --yes update + uses: ./.github/actions/apt/update - name: Install build dependencies - run: | - sudo apt --yes install \ - apache2-dev libcairo2-dev libcurl4-gnutls-dev libglib2.0-dev \ - libiniparser-dev libmapnik-dev - - name: Download build artifacts + uses: ./.github/actions/apt/install + with: + packages: ${{ env.build-dependencies }} + - name: Download build archive uses: actions/download-artifact@v2 with: - name: build + name: build-archive path: /tmp - name: Extract build archive - run: tar --verbose --extract --directory=/ --file=/tmp/workspace.tar + uses: ./.github/actions/build-archive/extract - name: Run `make test` run: make test @@ -99,25 +108,22 @@ jobs: - build - lint-astyle steps: + - name: Checkout code + uses: actions/checkout@v2 - name: Update installed packages - run: sudo apt --yes update - - name: Install build dependencies - run: | - sudo apt --yes install \ - apache2-dev libcairo2-dev libcurl4-gnutls-dev libglib2.0-dev \ - libiniparser-dev libmapnik-dev libjs-leaflet - - name: Install Apache HTTP Server - run: | - sudo apt --yes install \ - apache2 - - name: Download build artifacts + uses: ./.github/actions/apt/update + - name: Install build & test dependencies + uses: ./.github/actions/apt/install + with: + packages: ${{ env.build-dependencies }} apache2 libjs-leaflet + - name: Download build archive uses: actions/download-artifact@v2 with: - name: build + name: build-archive path: /tmp - name: Extract build archive - run: tar --verbose --extract --directory=/ --file=/tmp/workspace.tar - - name: Set up Apache HTTP Server + uses: ./.github/actions/build-archive/extract + - name: Configure Apache HTTP Server run: | sudo mkdir --parents /run/renderd /var/cache/renderd/tiles sudo ln --symbolic \