Skip to content

Commit

Permalink
chore(ci) cache httpbin docker image
Browse files Browse the repository at this point in the history
CI has been failing rather frequently due to Docker registry returning
`502 Bad Gateway` when the `setup-httpbin-server` action attempts to
pull httpbin's docker image.

This image is pulled by 16 jobs (Unit and Valgrind) for every GHA
workflow run. This might explain why we eventually fail to pull it.

Caching it should greatly reduce the number of times httpbin image is
actually pulled.
  • Loading branch information
casimiro committed Oct 29, 2024
1 parent f3e2b6a commit 9b0a258
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/actions/setup-httpbin-server/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ runs:
sudo apt-get update
sudo apt-get install -y dnsmasq
- name: 'Setup deps - macOS'
if: ${{ contains(inputs.os, 'macos') }}
shell: bash
run: |
brew install dnsmasq docker colima
colima start --network-address
- name: Setup Docker image tag
id: setup
shell: bash
Expand All @@ -54,16 +56,19 @@ runs:
echo "push=false" >> $GITHUB_OUTPUT
echo "tag=wasmx-ci-httpbin-proxy:latest" >> $GITHUB_OUTPUT
fi
- name: Login to GitHub Container Registry
if: ${{ steps.setup.outputs.push == 'true' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ inputs.ghcr_username }}
password: ${{ inputs.ghcr_password }}

- name: Setup Docker Buildx
if: ${{ !env.ACT }}
uses: docker/setup-buildx-action@v3

- name: Build httpbin-proxy image
uses: docker/build-push-action@v5
with:
Expand All @@ -74,6 +79,32 @@ runs:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max

# Cache httpbin docker image to prevent abusing Docker registry

- name: Create cache directory for httpbin Docker image
shell: bash
run: mkdir -p ~/image-cache

- name: Setup httpbin Docker image cache
id: image-cache
uses: actions/cache@v4
with:
path: ~/image-cache
key: httpbin-docker-image

- name: Pull httpbin Docker image
if: steps.image-cache.outputs.cache-hit != 'true'
shell: bash
run: |
docker pull kennethreitz/httpbin
docker save -o ~/image-cache/httpbin.tar kennethreitz/httpbin
- name: Load httpbin Docker image from cache
if: steps.image-cache.outputs.cache-hit == 'true'
shell: bash
run: docker load -i ~/image-cache/httpbin.tar

- name: Start dnsmasq
shell: bash
run: |
Expand All @@ -83,6 +114,7 @@ runs:
--server=${{ inputs.upstream_dns_server }} \
--address=/httpbin.org/127.0.0.1 \
--address=/example.com/127.0.0.1
- name: Start httpbin proxy + server
shell: bash
run: |
Expand Down

0 comments on commit 9b0a258

Please sign in to comment.