mirror of
https://github.com/lwthiker/curl-impersonate.git
synced 2026-08-25 21:58:12 +00:00
Add layer caching to speed up the CI builds. In addition, optimize the Dockerfiles by moving all the dependency installations (which are unlikely to change much) to the initial layers.
79 lines
2.4 KiB
YAML
79 lines
2.4 KiB
YAML
name: Build and test
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build-and-test:
|
|
name: Build curl-impersonate and run the tests
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
# A local registry is needed to push the build images to because we use
|
|
# the 'docker-container' driver. See
|
|
# https://github.com/docker/buildx/issues/301
|
|
# and
|
|
# See https://github.com/docker/build-push-action/blob/master/docs/advanced/local-registry.md
|
|
registry:
|
|
image: registry:2
|
|
ports:
|
|
- 5000:5000
|
|
steps:
|
|
- name: Check out the repo
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
with:
|
|
driver-opts: network=host
|
|
|
|
# Set up Docker caching. See
|
|
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md
|
|
- name: Cache Docker layers
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-buildx-
|
|
|
|
- name: Build the Chrome version of curl-impersonate
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
push: true
|
|
context: chrome/
|
|
tags: localhost:5000/curl-impersonate/chrome
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
|
|
|
- name: Build the Firefox version of curl-impersonate
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
push: true
|
|
context: firefox/
|
|
tags: localhost:5000/curl-impersonate/ff
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
|
|
|
- name: Build the tests container
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
load: true
|
|
context: tests/
|
|
tags: curl-impersonate-tests:latest
|
|
build-args: |
|
|
FIREFOX_IMAGE=localhost:5000/curl-impersonate/ff
|
|
CHROME_IMAGE=localhost:5000/curl-impersonate/chrome
|
|
|
|
- name: Run the tests
|
|
run: docker run --rm curl-impersonate-tests --log-cli-level DEBUG
|
|
|
|
# Temp fix
|
|
# https://github.com/docker/build-push-action/issues/252
|
|
# https://github.com/moby/buildkit/issues/1896
|
|
- name: Move cache
|
|
run: |
|
|
rm -rf /tmp/.buildx-cache
|
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|