Skip to content

Commit

Permalink
fix: fixed github actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
NatalieShaked committed Dec 18, 2024
1 parent 0c27dc1 commit 07f1a2d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 19 deletions.
70 changes: 53 additions & 17 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:

steps:
- name: Check out Git repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 12
node-version: 20

- name: Install dependencies
run: npm ci
Expand All @@ -29,10 +29,11 @@ jobs:
eslint_extensions: ts

- name: OpenAPI Lint Checks
if: ${{ inputs.enableOpenApiCheck == true }}
uses: nwestfall/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
file: ./openapi3.yaml
github_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ inputs.openApiFilePath }}

tests:
name: Run Tests
Expand All @@ -46,7 +47,6 @@ jobs:
image: redis
# Provide the password for postgres
env:
REDIS_HOST: localhost
REDIS_PORT: 6379
REDIS_USERNAME: ""
REDIS_PASSWORD: ""
Expand All @@ -60,22 +60,31 @@ jobs:
--health-timeout 5s
--health-retries 5
zookeeper:
image: bitnami/zookeeper:3.8.0
ports:
- 2181:2181
env:
ALLOW_ANONYMOUS_LOGIN: yes

kafka:
# Docker Hub image
image: apache/kafka:3.8.0
# Provide the password for postgres
image: bitnami/kafka:3.8.0
ports:
- 9092:9092
env:
KAFKA_BROKERS: localhost:9092
# Set health checks to wait until postgres has started

outputTopic:
image: ''
env:
KAFKA_OUTPUT_TOPIC: testTopic
KAFKA_BROKER_ID: 1
KAFKA_CFG_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
ALLOW_PLAINTEXT_LISTENER: yes
options: >-
--health-cmd "kafka-topics.sh --bootstrap-server localhost:9092 --list || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
matrix:
node: [14.x, 16.x]
node: [18.x, 20.x]

steps:
- name: Check out Git repository
Expand All @@ -89,14 +98,41 @@ jobs:
- name: Install Node.js dependencies
run: npm ci

- name: Install Docker
run: |
apt-get update
apt-get install -y docker.io
- name: Wait for Kafka
run: |
until docker exec $(docker ps -qf "name=kafka") kafka-topics.sh --list --bootstrap-server localhost:9092; do
echo "Waiting for Kafka to be ready...";
sleep 5;
done
- name: Create Kafka testTopic
run: |
docker exec $(docker ps -qf "name=kafka") \
kafka-topics.sh --create --topic testTopic --bootstrap-server localhost:9092
- name: Run tests
run: npm run test

- uses: actions/upload-artifact@v2
with:
name: Test Reporters
name: Test Reporters (Node ${{ matrix.node }})
path: reports/**

security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/node@master
continue-on-error: true
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

build_image:
name: Build Image
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions config/test.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"redis": {
"host": "localhost",
"host": "redis",
"port": 6379,
"username": "",
"password": "",
Expand All @@ -13,7 +13,7 @@
"database": 1
},
"kafka": {
"brokers": "localhost:9092"
"brokers": "kafka:9092"
},
"kafkaConsumer": {},
"kafkaProducer": {},
Expand Down

0 comments on commit 07f1a2d

Please sign in to comment.