Skip to content

Commit

Permalink
Port CircleCI to Github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Oct 16, 2023
1 parent dbab9a6 commit 56c9a8d
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 111 deletions.
111 changes: 0 additions & 111 deletions .circleci/config.yml

This file was deleted.

91 changes: 91 additions & 0 deletions .github/workflows/build-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Build and Publish Docker image

on:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- v[0-9]+.[0-9]+.[0-9]+

jobs:
build-and-publish:
runs-on: ubuntu-latest
env:
TEST_TAG: ${{ github.repository }}:test
TEST_CONTAINER_NAME: container-healthcheck
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch everything (tags)
- name: Set tag version
run: echo "VERSION_TAG=$(git describe --tags --abbrev=4)" >> $GITHUB_ENV
- name: Build `version.json` file
run: |
printf '{\n "commit": "%s",\n "version": "%s",\n "source": "%s",\n "build": "%s"\n}\n' \
"$GITHUB_SHA" \
"$VERSION_TAG" \
"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \
"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" > ./version.json
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ github.repository }}
# https://github.com/marketplace/actions/docker-metadata-action#tags-input
tags: |
type=semver,pattern={{raw}}
type=raw,value=latest,enable={{is_default_branch}}
type=sha,enable={{is_default_branch}}
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and export to Docker
uses: docker/build-push-action@v3
with:
context: .
load: true
push: false
tags: ${{ env.TEST_TAG }}

- run:
name: Test from Docker
command: docker run \
-it \
--user root \
--name ${{ env.TEST_CONTAINER_NAME }} \
${{ env.TEST_TAG }} \
test

- name: Spin up container
run: |
docker run \
--name ${{ env.TEST_CONTAINER_NAME }} \
--detach \
--env CONFIG_FILE=/app/tests/checks/remotesettings/config.toml \
--publish 8000:8000 \
${{ env.TEST_TAG }}
- name: Check that container is running
run: |
docker exec ${{ env.TEST_CONTAINER_NAME }} curl --retry 10 --retry-delay 1 --retry-connrefused http://0.0.0.0:8000/checks | grep remotesettings
- name: Spin down container
run: |
docker rm -f ${{ env.TEST_CONTAINER_NAME }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
38 changes: 38 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Run CI checks

on: pull_request

jobs:
run_lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "poetry"
- name: Run lint
run: make lint
run_test:
runs-on: ubuntu-latest
env:
CURL_BINARY_PATH: /home/circleci/.local/bin/curl
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "poetry"
- name: Get curl with HTTP2 and HTTP3 support
run: |
wget https://github.com/stunnel/static-curl/releases/download/8.1.1/curl-static-amd64-8.1.1.tar.xz
tar -xvf curl-*.tar.xz
mv curl $CURL_BINARY_PATH
- name: Install dependencies
run: poetry install
- name: Run tests
run: make tests

0 comments on commit 56c9a8d

Please sign in to comment.