Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GitHub Actions workflows #2226

Merged
merged 13 commits into from
Feb 19, 2025
8 changes: 4 additions & 4 deletions .github/workflows/ci-deploy-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
outputs:
image: ${{ steps.build-image.outputs.image }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand All @@ -26,13 +26,13 @@ jobs:

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
uses: aws-actions/amazon-ecr-login@v2

- name: Set up Docker Buildx
uses: crazy-max/ghaction-docker-buildx@v3

- name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@v4
id: cache
with:
path: /tmp/.buildx-cache
Expand Down
48 changes: 24 additions & 24 deletions .github/workflows/ci-push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,50 @@ jobs:
runs-on: ubuntu-latest

outputs:
image: ${{ steps.build-image.outputs.image }}
image: ${{ steps.build-push.outputs.imageid }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: eu-west-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Set up Docker Buildx
uses: crazy-max/ghaction-docker-buildx@v3
uses: aws-actions/amazon-ecr-login@v2

- name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@v4
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Docker Buildx (+ push)
id: push-image-to-ecr
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ github.event.repository.name }}
IMAGE_TAG: ${{ github.sha }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- id: set-vars
run: |
BRANCH=$(echo "${GITHUB_REF#refs/*/}" | sed 's/.*\///')
# push with git sha and branch
echo "Pushing to $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
docker buildx build \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache-new" \
--platform "linux/amd64,linux/arm64" \
--output "type=image,push=true" \
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
--tag $ECR_REGISTRY/$ECR_REPOSITORY:$BRANCH \
--file ./Dockerfile ./
echo "ECR_TAG_SHA=${{ steps.login-ecr.outputs.registry }}/${{ github.event.repository.name }}:${{ github.sha }}" >> "$GITHUB_OUTPUT"
echo "ECR_TAG_BRANCH=${{ steps.login-ecr.outputs.registry }}/${{ github.event.repository.name }}:"${BRANCH} >> "$GITHUB_OUTPUT"

- name: Build and push
uses: docker/build-push-action@v6
id: build-push
with:
context: .
file: production/Dockerfile
push: true
tags: ${{ steps.set-vars.outputs.ECR_TAG_SHA }},${{ steps.set-vars.outputs.ECR_TAG_BRANCH }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
outputs: type=image,push=true

- name: Reset cache
id: reset-cache
Expand Down
42 changes: 21 additions & 21 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up Enviroments
- name: Set up Enviroments
run: |
export RECORD_RUNTIME=true
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export LANGUAGE=C.UTF-8
export PATH=/root/.local/bin:$PATH
rm -rf tmp/cache tmp/cache1 tmp/cache2 tmp/cache3 tmp/cache4 tmp/cache5 && mkdir -p tmp/cache tmp/cache1 tmp/cache2 tmp/cache3 tmp/cache4 tmp/cache5

- name: Set up Configuration Files
run: |
cp config/config.yml.example config/config.yml
cp config/database.yml.example config/database.yml
cp config/sidekiq.yml.example config/sidekiq.yml
cp config/credentials.json.example config/credentials.json
cp config/sidekiq-test.yml.example config/sidekiq-test.yml

- name: Build Docker Container
run: |
docker compose build
Expand All @@ -79,14 +79,14 @@ jobs:
sleep 10
touch tmp/parallel_runtime_test.log
chmod +w tmp/parallel_runtime_test.log

- name: Run Functional Tests
id: functional-tests
env:
TEST_RETRY_COUNT: 3
run: |
docker compose exec -e TEST_RETRY_COUNT=$TEST_RETRY_COUNT -T -e PATTERN='models mailers integration workers lib contract' api test/run-tests.sh

- name: After Functional Test
env:
GITHUB_EVENT: ${{ github.event_name}}
Expand Down Expand Up @@ -115,8 +115,8 @@ jobs:
-e ROLE_TO_ASSUME=$AWS_ROLE_TO_ASSUME \
-e AWS_REGION=$AWS_REGION \
-e AWS_CONFIG_FILE=/app/credentials api test/test-coverage.sh


unit-tests:
runs-on: ubuntu-latest

Expand All @@ -141,23 +141,23 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: set up enviromnts
- name: set up enviromnts
run: |
export RECORD_RUNTIME=true
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export LANGUAGE=C.UTF-8
export PATH=/root/.local/bin:$PATH
rm -rf tmp/cache tmp/cache1 tmp/cache2 tmp/cache3 tmp/cache4 tmp/cache5 && mkdir -p tmp/cache tmp/cache1 tmp/cache2 tmp/cache3 tmp/cache4 tmp/cache5

- name: Set up Configuration Files
run: |
cp config/config.yml.example config/config.yml
cp config/database.yml.example config/database.yml
cp config/sidekiq.yml.example config/sidekiq.yml
cp config/credentials.json.example config/credentials.json
cp config/sidekiq-test.yml.example config/sidekiq-test.yml

- name: Build Docker Container
run: |
docker compose build
Expand All @@ -182,14 +182,14 @@ jobs:
sleep 10
touch tmp/parallel_runtime_test.log
chmod +w tmp/parallel_runtime_test.log

- name: Run Unit Tests
id: unit-tests
env:
TEST_RETRY_COUNT: 3
run: |
docker compose exec -e TEST_RETRY_COUNT=$TEST_RETRY_COUNT -T -e PATTERN='controllers contract' api test/run-tests.sh

- name: After Unit Test
env:
GITHUB_EVENT: ${{ github.event_name}}
Expand Down Expand Up @@ -219,7 +219,7 @@ jobs:
-e AWS_REGION=$AWS_REGION \
-e AWS_CONFIG_FILE=/app/credentials api test/test-coverage.sh


contract-tests:
runs-on: ubuntu-latest

Expand All @@ -244,39 +244,39 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up Enviroments
- name: Set up Enviroments
run: |
export RECORD_RUNTIME=true
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export LANGUAGE=C.UTF-8
export PATH=/root/.local/bin:$PATH
rm -rf tmp/cache tmp/cache1 tmp/cache2 tmp/cache3 tmp/cache4 tmp/cache5 && mkdir -p tmp/cache tmp/cache1 tmp/cache2 tmp/cache3 tmp/cache4 tmp/cache5

- name: Set up Configuration Files
run: |
cp config/config.yml.example config/config.yml
cp config/database.yml.example config/database.yml
cp config/sidekiq.yml.example config/sidekiq.yml
cp config/credentials.json.example config/credentials.json
cp config/sidekiq-test.yml.example config/sidekiq-test.yml

- name: Build Docker Container
run: |
docker compose build

- name: Run syntax checks
run: |
docker compose run api bash -c 'touch /tmp/no-syntax-errors && find app lib config -name *.rb -exec bash -c "ruby -c {} >/dev/null || rm /tmp/no-syntax-errors" ";" && ls /tmp/no-syntax-errors'

- name: Run Container
run: docker compose -f docker-compose.yml -f docker-test.yml up -d

- name: Wait for the server to be ready
run: |
tail -f log/test.log &
until curl --silent -I -f --fail http://localhost:3000 ; do printf .; sleep 1; done

- name: Set up Parallel Environment
run: docker compose exec -T api test/setup-parallel-env.sh

Expand All @@ -288,14 +288,14 @@ jobs:
sleep 10
touch tmp/parallel_runtime_test.log
chmod +w tmp/parallel_runtime_test.log

- name: Run Contract Tests
id: run-tests
env:
TEST_RETRY_COUNT: 3
run: |
docker compose exec -e TEST_RETRY_COUNT=$TEST_RETRY_COUNT -T -e PATTERN='controllers models mailers integration workers lib' api test/run-tests.sh

- name: After Contract Test
env:
GITHUB_EVENT: ${{ github.event_name}}
Expand Down
Loading