-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (93 loc) · 3.14 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Build
on: [ push, workflow_dispatch ]
jobs:
setup:
runs-on: ubuntu-latest
outputs:
build_url: ${{ steps.data.outputs.build_url }}
steps:
- id: data
name: Populates outputs
run: |
echo "build_url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" >> "$GITHUB_OUTPUT"
test:
if: github.event_name != 'release'
needs: setup
env:
COMPOSE_FILE: docker-compose.yml:docker-compose.ci.yml
DOCKER_APP_IMAGE: app-run-${{ github.run_id}}
outputs:
imageid: ${{ steps.image }}
permissions:
packages: write
contents: read
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
os_family:
- linux
architecture:
- amd64
- arm64
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- id: meta
name: Construct image tags and labels
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/berkeleylibrary/geodata
labels: |
edu.berkeley.lib.build-timestamp=${{ github.event.repository.updated_at }}
edu.berkeley.lib.build-url=${{ needs.setup.outputs.build_url }}
edu.berkeley.lib.git-ref-name=${{ github.ref_name }}
edu.berkeley.lib.git-repository-url=${{ github.repositoryUrl }}
edu.berkeley.lib.git-sha=${{ github.sha }}
tags: |
type=raw,value=${{ env.DOCKER_APP_IMAGE }}
type=sha
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- id: image
name: Build the docker image
uses: docker/build-push-action@v6
with:
context: .
build-args: |
BUILD_TIMESTAMP=${{ github.event.repository.updated_at }}
BUILD_URL=${{ needs.setup.outputs.build_url }}
GIT_REF_NAME=${{ github.ref_name }}
GIT_REPOSITORY_URL=${{ github.repositoryUrl }}
GIT_SHA=${{ github.sha }}
platforms: ${{ matrix.os_family }}/${{ matrix.architecture }}
push: false
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
- name: Start the stack
run: |
docker compose up --build --detach
sleep 10
- name: Run RSpec tests
run: |
docker compose exec -e RAILS_ENV=test app rake
- name: Extract service logs
if: ${{ always() }}
run: |
mkdir -p tmp/artifacts
docker compose logs > tmp/artifacts/docker-compose.log
docker compose cp app:/opt/app/artifacts/ tmp/
- name: Upload testing artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os_family }}-${{ matrix.architecture }}
path: tmp/artifacts