-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
129 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Run tests and push Docker image on success | ||
|
||
"on": | ||
push: | ||
branches: [main] | ||
pull_request: | ||
release: | ||
types: [published] | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
test-and-push: | ||
runs-on: [ubuntu] | ||
permissions: | ||
contents: write | ||
id-token: write | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Context for Buildx | ||
id: buildx-context | ||
run: docker context use builders || docker context create builders | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
with: | ||
version: latest | ||
endpoint: builders | ||
|
||
- name: Log in to GitHub Container Registry | ||
id: ghcr_login | ||
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Prep Tags | ||
id: prep | ||
run: | | ||
TAG=noop | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
TAG=${GITHUB_REF#refs/tags/} | ||
elif [[ $GITHUB_REF == refs/pull/* ]]; then | ||
TAG="sha-${GITHUB_SHA::8}" | ||
elif [ "${{ github.event_name }}" = "push" ]; then | ||
TAG="sha-${GITHUB_SHA::8}" | ||
fi | ||
echo ::set-output name=tag::${TAG} | ||
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
- name: Build image | ||
run: make build | ||
env: | ||
NETWORK: host | ||
IMAGE_TAG: ${{ steps.prep.outputs.tag }} | ||
|
||
- name: Run Python tests (docker-compose) | ||
run: make clean && make test | ||
env: | ||
NETWORK: default | ||
IMAGE_TAG: ${{ steps.prep.outputs.tag }} | ||
|
||
- name: Push image | ||
run: make push | ||
env: | ||
IMAGE_TAG: ${{ steps.prep.outputs.tag }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,68 @@ | ||
--- | ||
name: 🧪 Test | ||
# --- | ||
# name: 🧪 Test | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
# on: | ||
# pull_request: | ||
# branches: | ||
# - main | ||
|
||
permissions: {} | ||
# permissions: {} | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
id-token: write | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
id: checkout | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
# jobs: | ||
# test: | ||
# name: Test | ||
# runs-on: ubuntu-latest | ||
# permissions: | ||
# contents: write | ||
# id-token: write | ||
# packages: write | ||
# steps: | ||
# - name: Checkout | ||
# id: checkout | ||
# uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
|
||
# - name: Set Up Container Structure Test | ||
# id: setup_container_structure_test | ||
# uses: ministryofjustice/github-actions/setup-container-structure-test@ccf9e3a4a828df1ec741f6c8e6ed9d0acaef3490 # v18.5.0 | ||
# # - name: Set Up Container Structure Test | ||
# # id: setup_container_structure_test | ||
# # uses: ministryofjustice/github-actions/setup-container-structure-test@ccf9e3a4a828df1ec741f6c8e6ed9d0acaef3490 # v18.5.0 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
# - name: Set up Docker Buildx | ||
# uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Install Docker Compose | ||
id: docker-compose | ||
shell: bash | ||
env: | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
sudo curl -L "https://github.com/docker/compose/releases/download/v2.21.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | ||
sudo chmod +x /usr/local/bin/docker-compose | ||
docker-compose --version | ||
# - name: Install Docker Compose | ||
# id: docker-compose | ||
# shell: bash | ||
# env: | ||
# IMAGE_TAG: ${{ github.sha }} | ||
# run: | | ||
# sudo curl -L "https://github.com/docker/compose/releases/download/v2.21.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | ||
# sudo chmod +x /usr/local/bin/docker-compose | ||
# docker-compose --version | ||
|
||
- name: Build with Docker Compose | ||
id: build | ||
shell: bash | ||
env: | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
make build | ||
# - name: Build with Docker Compose | ||
# id: build | ||
# shell: bash | ||
# env: | ||
# IMAGE_TAG: ${{ github.sha }} | ||
# run: | | ||
# make build | ||
|
||
- name: Log in to GitHub Container Registry | ||
id: ghcr_login | ||
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
# - name: Log in to GitHub Container Registry | ||
# id: ghcr_login | ||
# uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 | ||
# with: | ||
# registry: ghcr.io | ||
# username: ${{ github.actor }} | ||
# password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Push | ||
id: push | ||
env: | ||
IMAGE_NAME: ghcr.io/ministryofjustice/analytics-platform-control-panel | ||
run: | | ||
docker push $IMAGE_NAME:${{ github.sha }} | ||
# - name: Push | ||
# id: push | ||
# env: | ||
# IMAGE_NAME: ghcr.io/ministryofjustice/analytics-platform-control-panel | ||
# run: | | ||
# docker push $IMAGE_NAME:${{ github.sha }} | ||
|
||
- name: Run tests | ||
env: | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
make test-python | ||
# - name: Run tests | ||
# env: | ||
# IMAGE_TAG: ${{ github.sha }} | ||
# run: | | ||
# make test-python |