mirror of
https://github.com/lwthiker/curl-impersonate.git
synced 2026-08-25 20:18:15 +00:00
Merge pull request #22 from lwthiker/github_actions
Add GitHub actions workflow to build and test curl-impersonate
This commit is contained in:
78
.github/workflows/build-and-test.yml
vendored
Normal file
78
.github/workflows/build-and-test.yml
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
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
|
||||
@@ -1,3 +1,5 @@
|
||||
# curl-impersonate · 
|
||||
|
||||
A special compilation of [curl](https://github.com/curl/curl) that makes it impersonate real browsers. Currently supports Chrome, Edge & Firefox. This curl binary is able to perform a TLS handshake that is identical to that of a real browser.
|
||||
|
||||
## Why?
|
||||
|
||||
@@ -7,6 +7,10 @@ WORKDIR /build
|
||||
RUN apt-get update && \
|
||||
apt-get install -y git g++ cmake golang-go ninja-build curl unzip zlib1g-dev libbrotli-dev
|
||||
|
||||
# The following are needed because we are going to change some autoconf scripts,
|
||||
# both for libnghttp2 and curl.
|
||||
RUN apt-get install -y autoconf automake autotools-dev pkg-config libtool
|
||||
|
||||
# BoringSSL doesn't have versions. Choose a commit that is used in a stable
|
||||
# Chromium version.
|
||||
ARG BORING_SSL_COMMIT=3a667d10e94186fd503966f5638e134fe9fb4080
|
||||
@@ -33,10 +37,6 @@ RUN mkdir boringssl/build/lib && \
|
||||
ARG NGHTTP2_VERSION=nghttp2-1.46.0
|
||||
ARG NGHTTP2_URL=https://github.com/nghttp2/nghttp2/releases/download/v1.46.0/nghttp2-1.46.0.tar.bz2
|
||||
|
||||
# The following are needed because we are going to change some autoconf scripts,
|
||||
# both for libnghttp2 and curl.
|
||||
RUN apt-get install -y autoconf automake autotools-dev pkg-config libtool
|
||||
|
||||
# Download nghttp2 for HTTP/2.0 support.
|
||||
RUN curl -o ${NGHTTP2_VERSION}.tar.bz2 -L ${NGHTTP2_URL}
|
||||
RUN tar xf ${NGHTTP2_VERSION}.tar.bz2
|
||||
|
||||
@@ -8,6 +8,15 @@ WORKDIR /build
|
||||
RUN apt-get update && \
|
||||
apt-get install -y mercurial git ninja-build python3-pip curl zlib1g-dev libbrotli-dev
|
||||
|
||||
# The following are needed because we are going to change some autoconf scripts,
|
||||
# both for libnghttp2 and curl.
|
||||
RUN apt-get install -y autoconf automake autotools-dev pkg-config libtool
|
||||
|
||||
# curl tries to load the CA certificates for libnss.
|
||||
# It loads them from /usr/lib/x86_64-linux-gnu/nss/libnssckbi.so,
|
||||
# which is supplied by libnss3 on Debian/Ubuntu
|
||||
RUN apt-get install -y libnss3
|
||||
|
||||
# Also needed for building libnss
|
||||
RUN pip install gyp-next
|
||||
|
||||
@@ -24,10 +33,6 @@ RUN tar xf ${NSS_VERSION}.tar.gz && \
|
||||
ARG NGHTTP2_VERSION=nghttp2-1.46.0
|
||||
ARG NGHTTP2_URL=https://github.com/nghttp2/nghttp2/releases/download/v1.46.0/nghttp2-1.46.0.tar.bz2
|
||||
|
||||
# The following are needed because we are going to change some autoconf scripts,
|
||||
# both for libnghttp2 and curl.
|
||||
RUN apt-get install -y autoconf automake autotools-dev pkg-config libtool
|
||||
|
||||
# Download nghttp2 for HTTP/2.0 support.
|
||||
RUN curl -o ${NGHTTP2_VERSION}.tar.bz2 -L ${NGHTTP2_URL}
|
||||
RUN tar xf ${NGHTTP2_VERSION}.tar.bz2
|
||||
@@ -59,11 +64,6 @@ RUN cd ${CURL_VERSION} && \
|
||||
./configure --with-nss=/build/${NSS_VERSION}/dist/Release --enable-static --disable-shared CFLAGS="-I/build/${NSS_VERSION}/dist/public/nss -I/build/${NSS_VERSION}/dist/Release/include/nspr" --with-nghttp2=/usr/local USE_CURL_SSLKEYLOGFILE=true && \
|
||||
make
|
||||
|
||||
# curl tries to load the CA certificates for libnss.
|
||||
# It loads them from /usr/lib/x86_64-linux-gnu/nss/libnssckbi.so,
|
||||
# which is supplied by libnss3 on Debian/Ubuntu
|
||||
RUN apt-get install -y libnss3
|
||||
|
||||
RUN mkdir out && \
|
||||
cp ${CURL_VERSION}/src/curl out/curl-impersonate && \
|
||||
strip out/curl-impersonate
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
ARG FIREFOX_IMAGE=curl-impersonate-ff
|
||||
ARG CHROME_IMAGE=curl-impersonate-chrome
|
||||
|
||||
FROM ${FIREFOX_IMAGE} as ff
|
||||
FROM ${CHROME_IMAGE} as chrome
|
||||
|
||||
FROM python:3.10.1-slim-buster
|
||||
|
||||
WORKDIR /tests
|
||||
@@ -13,8 +19,8 @@ RUN pip install --upgrade pip && \
|
||||
RUN mkdir /tests/firefox /tests/chrome
|
||||
|
||||
# Copy the built binaries from both containers
|
||||
COPY --from=curl-impersonate-ff /build/out/* /tests/firefox/
|
||||
COPY --from=curl-impersonate-chrome /build/out/* /tests/chrome/
|
||||
COPY --from=ff /build/out/* /tests/firefox/
|
||||
COPY --from=chrome /build/out/* /tests/chrome/
|
||||
|
||||
COPY . .
|
||||
|
||||
|
||||
Reference in New Issue
Block a user