Skip to content

Commit

Permalink
chore: make tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
AleF83 committed Mar 19, 2023
1 parent 1eb0961 commit 02d6636
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 57 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/addons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ name: Addons Tests
on:
push:
paths:
- 'addons/**'
- '.github/workflows/addons.yaml'
- 'addons/**'
- '.github/workflows/addons.yaml'
jobs:
run-context-tests:
runs-on: ubuntu-latest
container: mcr.microsoft.com/dotnet/sdk:5.0
env:
DOTNET_CLI_TELEMETRY_OPTOUT: "true"
REDIS_TEST_CONNECTION: "redis:6379"
MONGODB_TEST_CONNECTION: "mongodb://mongo:27017"
COUCHBASE_TEST_URL: "http://couchbase:8091"
DOTNET_CLI_TELEMETRY_OPTOUT: 'true'
REDIS_TEST_CONNECTION: 'redis:6379'
MONGODB_TEST_CONNECTION: 'mongodb://mongo:27017'
COUCHBASE_TEST_URL: 'http://couchbase:8091'

services:
redis:
Expand All @@ -23,17 +23,20 @@ jobs:
mongo:
image: mongo:3.6-jessie
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Test redis driver
working-directory: addons/Context/Tweek.Drivers.Context.Redis.IntegrationTests
run: |
dotnet test
dotnet test
- name: Test Couchbase driver
working-directory: addons/Context/Tweek.Drivers.Context.Couchbase.IntegrationTests
run: |
curl --retry 3 --retry-max-time 10 -v http://couchbase:8091/settings/web -d port=8091 -d username=Administrator -d password=password
curl --retry 3 --retry-max-time 10 -v -u Administrator:password -X POST http://couchbase:8091/pools/default/buckets -d authType=sasl -d name=testbucket -d ramQuotaMB=100 -d saslPassword=password
dotnet test
- name: Test Mongo driver
working-directory: addons/Context/Tweek.Drivers.Context.MongoDb.IntegrationTests
run: |
Expand Down
71 changes: 48 additions & 23 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,146 +3,171 @@ name: Main
on:
push:
paths-ignore:
- 'docs/**'
- README.md
- 'docs/**'
- README.md
jobs:
build-images:
runs-on: ubuntu-latest
strategy:
matrix:
image: ["authoring", "gateway", "publishing", "api", "editor"]
image: ['authoring', 'gateway', 'publishing', 'api', 'editor']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Login Docker DH
if: ${{ github.repository == 'soluto/tweek' }}
env:
DOCKERHUB_TOKEN: ${{ secrets.DOCKER_TOKEN }}
DOCKERHUB_USER: ${{ secrets.DOCKER_USER }}
run: echo $DOCKERHUB_TOKEN | docker login --username $DOCKERHUB_USER --password-stdin

- name: build
run: |
echo $GITHUB_REPOSITORY
yarn docker-compose build ${{ matrix.image }} && \
docker save -o ${{ matrix.image }}-${{ github.sha }}.tar soluto/tweek-${{ matrix.image }} && \
echo cp -a ${{ matrix.image }}-${{ github.sha }}.tar .github/workflows/
cp -a ${{ matrix.image }}-${{ github.sha }}.tar .github/workflows/
- name: 'Upload Artifact'
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: build-images
path: |
.github/workflows/${{ matrix.image }}-${{ github.sha }}.tar
run-e2e-ui:
needs: ["build-images"]
needs: ['build-images']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Download build images
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: build-images

- name: load images into docker
run: echo api publishing editor gateway authoring | xargs -n 1 | xargs -I {} docker load -i {}-$GITHUB_SHA.tar

- name: run tests
run: yarn && yarn test:docker:ui

run-e2e-integration:
needs: ["build-images"]
needs: ['build-images']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Download build images
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: build-images

- name: load images into docker
run: echo api publishing editor gateway authoring | xargs -n 1 | xargs -I {} docker load -i {}-$GITHUB_SHA.tar

- name: run integration tests
working-directory: e2e/integration
run: |
yarn && yarn start gateway && yarn test:docker
run-net-tests:
needs: ["build-images"]
needs: ['build-images']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Download build images
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: build-images

- name: load images into docker
run: echo api publishing editor gateway authoring | xargs -n 1 | xargs -I {} docker load -i {}-$GITHUB_SHA.tar

- name: run smoke tests
run: yarn && yarn test:docker:smoke

push-images:
needs: ["run-net-tests", "run-e2e-integration", "run-e2e-ui"]
needs: ['run-net-tests', 'run-e2e-integration', 'run-e2e-ui']
runs-on: ubuntu-latest
if: ${{ github.repository == 'soluto/tweek' && !startsWith(github.ref, 'refs/heads/dependabot') }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Login Docker DH
if: ${{ github.repository == 'soluto/tweek' }}
env:
DOCKERHUB_TOKEN: ${{ secrets.DOCKER_TOKEN }}
DOCKERHUB_USER: ${{ secrets.DOCKER_USER }}
run: echo $DOCKERHUB_TOKEN | docker login --username $DOCKERHUB_USER --password-stdin

- name: Download build images
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: build-images

- name: load images into docker
run: echo api publishing editor gateway authoring | xargs -n 1 | xargs -I {} docker load -i {}-$GITHUB_SHA.tar

- name: push branch
if: ${{ github.ref != 'refs/heads/master' }}
run: |
export GITHUB_BRANCH=$(echo $GITHUB_REF | sed -e "s/refs\/heads\///" -e "s/\//-/")
echo api publishing editor gateway authoring | xargs -n 1 | xargs -I {} docker tag soluto/tweek-{} soluto/tweek-{}:$GITHUB_BRANCH
echo api publishing editor gateway authoring | xargs -n 1 | xargs -I {} docker push soluto/tweek-{}:$GITHUB_BRANCH
- name: push master
if: ${{ github.ref == 'refs/heads/master' }}
run: |
echo api publishing editor gateway authoring | xargs -n 1 | xargs -I {} docker tag soluto/tweek-{} soluto/tweek-{}:latest
echo api publishing editor gateway authoring | xargs -n 1 | xargs -I {} docker push soluto/tweek-{}:latest
echo api publishing editor gateway authoring | xargs -n 1 | xargs -I {} docker tag soluto/tweek-{} soluto/tweek-{}:$GITHUB_SHA
echo api publishing editor gateway authoring | xargs -n 1 | xargs -I {} docker push soluto/tweek-{}:$GITHUB_SHA
- name: check versions
if: ${{ github.ref == 'refs/heads/master' }}
working-directory: ".github/workflows"
working-directory: '.github/workflows'
run: |
./versions_to_deploy.sh
- name: Push new api version
if: ${{ github.ref == 'refs/heads/master' && env.TWEEK_API_VERSION != '' }}
working-directory: ".github/workflows"
working-directory: '.github/workflows'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./push-tag.sh api $TWEEK_API_VERSION
- name: Push new editor version
if: ${{ github.ref == 'refs/heads/master' && env.TWEEK_EDITOR_VERSION != '' }}
working-directory: ".github/workflows"
working-directory: '.github/workflows'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./push-tag.sh editor $TWEEK_EDITOR_VERSION
- name: Push new authoring version
if: ${{ github.ref == 'refs/heads/master' && env.TWEEK_AUTHORING_VERSION != '' }}
working-directory: ".github/workflows"
working-directory: '.github/workflows'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./push-tag.sh authoring $TWEEK_AUTHORING_VERSION
- name: Push new publishing version
if: ${{ github.ref == 'refs/heads/master' && env.TWEEK_PUBLISHING_VERSION != '' }}
working-directory: ".github/workflows"
working-directory: '.github/workflows'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./push-tag.sh publishing $TWEEK_PUBLISHING_VERSION
- name: Push new gateway version
if: ${{ github.ref == 'refs/heads/master' && env.TWEEK_GATEWAY_VERSION != '' }}
working-directory: ".github/workflows"
working-directory: '.github/workflows'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand Down
3 changes: 2 additions & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
docker_compose("./deployments/dev/tilt.yml" )
docker_build("soluto/tweek-gateway", "services/gateway",dockerfile="services/gateway/debug.Dockerfile")
docker_build("soluto/tweek-gateway", "services/gateway",dockerfile="services/gateway/Dockerfile")

docker_build("soluto/tweek-authoring", "services/authoring")
docker_build("soluto/tweek-api", ".", dockerfile="TweekApi.Dockerfile")
Expand All @@ -10,6 +10,7 @@ docker_build("soluto/tweek-editor", "services/editor",dockerfile="services/edito
sync('services/editor/src', '/app/src'),
]
)
docker_build("soluto/tweek-bare-repo", "services/git-service/BareRepository")

dc_resource('minio')
dc_resource('redis')
Expand Down
8 changes: 6 additions & 2 deletions deployments/dev/tilt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ services:
- publishing
environment:
NODE_TLS_REJECT_UNAUTHORIZED: '0'
NODE_OPTIONS: "--max-old-space-size=8192"
GIT_PRIVATE_KEY_PATH: /run/secrets/tweek_ssh_private_key
GIT_PUBLIC_KEY_PATH: /run/secrets/tweek_ssh_public_key
GIT_URL: ssh://git@publishing/tweek/repo
Expand Down Expand Up @@ -83,6 +84,7 @@ services:
- nats
- oidc-server-mock
environment:
CONFIGOR_ENV: development
TWEEKGATEWAY_CONFIGFILEPATH: /config/gateway.json
TWEEKGATEWAY_SECURITY_AUTH_BASICAUTH_REDIRECTURLS: '[''http://localhost:8081'',
''http://localhost:3000'']'
Expand Down Expand Up @@ -118,11 +120,13 @@ services:
secrets:
- source: tweek_ssh_public_key
minio:
command: server /data
image: minio/minio
command: server /data --console-address ":9001"
image: minio/minio:RELEASE.2022-05-19T18-20-59Z.hotfix.30a60091e
ports:
- published: 4007
target: 9000
- published: 4012
target: 9001
secrets:
- source: minio_access_key
target: access_key
Expand Down
2 changes: 1 addition & 1 deletion e2e/integration/spec/authoring-api/extractionRules.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('authoring api extraction rules', () => {

const originalRules = buf.toString();
const newRules = originalRules + '\n'; // only adding new line in order not to break the original rules

await pollUntil(
() => getObjectContentFromMinio('security/subject_extraction_rules.rego'),
(res) => expect(res).to.contain(originalRules),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package rules
default subject = { "user": null, "group": null }

subject = { "user": "admin-app", "group": "externalapps"} {
startswith(input.iss, "https://localhost:")
input.aud = "tweek-openid-mock-client"
input.sub = "user"
} else = { "user": input.sub, "group": "default" } {
Expand Down
2 changes: 1 addition & 1 deletion e2e/integration/spec/tweek-api/context.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('tweek api - context', () => {
});
});

it('should return bad response when trying to append context with bad property type', async () => {
it.only('should return bad response when trying to append context with bad property type', async () => {
await client
.post(`/api/v2/context/${identityType}/user-1`)
.send({ AgentVersion: 'not a version' })
Expand Down
6 changes: 3 additions & 3 deletions e2e/integration/utils/minio.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ module.exports.getObjectContentFromMinio = async (objectName) => {
if (!stream) {
return reject('stream is null.');
}
const contentChuncks = [];
stream.on('data', (chunk) => contentChuncks.push(chunk));
const contentChunks = [];
stream.on('data', (chunk) => contentChunks.push(chunk));
stream.on('end', () => {
return resolve(contentChuncks.join(''));
return resolve(contentChunks.join(''));
});
stream.on('error', (err) => {
return reject(err);
Expand Down
1 change: 0 additions & 1 deletion services/gateway/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Dockerfile*
debug.Dockerfile
docker-compose*
.dockerignore
.git
Expand Down
16 changes: 0 additions & 16 deletions services/gateway/debug.Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ build:
- src: '**/*.go'
dest: /app
docker:
dockerfile: debug.Dockerfile
dockerfile: Dockerfile
- image: soluto/tweek-editor
context: services/editor
sync:
Expand Down

0 comments on commit 02d6636

Please sign in to comment.