diff --git a/.github/workflows/check_build.yml b/.github/workflows/check_build.yml new file mode 100644 index 00000000..5f13de01 --- /dev/null +++ b/.github/workflows/check_build.yml @@ -0,0 +1,21 @@ +name: Build EE2 Docker Image + +on: + pull_request + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Build and push + uses: docker/build-push-action@v6 + with: + push: false + tags: ee2/test:test \ No newline at end of file diff --git a/.github/workflows/ee2-tests.yml b/.github/workflows/ee2-tests.yml index 0e03c03e..c8397e64 100644 --- a/.github/workflows/ee2-tests.yml +++ b/.github/workflows/ee2-tests.yml @@ -1,12 +1,6 @@ # This workflow will install Python dependencies, run tests and lint # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -# To ssh into this build add the following: -#- name: Start SSH session -# uses: luchihoratiu/debug-via-ssh@main -# with: -# NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }} -# SSH_PASS: ${{ secrets.SSH_PASS }} name: Execution Engine 2 Test Suite @@ -50,9 +44,17 @@ jobs: path: "./test" + Build_and_Run_Tests_and_CodeCov: name: Build and Run Tests and CodeCov runs-on: ubuntu-latest + strategy: + matrix: + mongo-config: + - version: "7.0" + init-path: "./test/dockerfiles/mongo/docker-entrypoint-initdb.d-7.0/" + - version: "3.6" + init-path: "./test/dockerfiles/mongo/docker-entrypoint-initdb.d-3.6/" steps: - name: Check out source repository uses: actions/checkout@v4 @@ -64,12 +66,16 @@ jobs: run: | pip install -r requirements.txt git clone https://github.com/kbase/jars /opt/jars - - name: Build Docker Image + - name: Set MongoDB Version and Init Path run: | - docker build . -t execution_engine2:test - - name: Run Tests + echo "MONGO_VERSION=${{ matrix.mongo-config.version }}" >> $GITHUB_ENV + echo "INIT_PATH=${{ matrix.mongo-config.init-path }}" >> $GITHUB_ENV + - name: Start Services and Run Tests run: | docker compose up -d cp test/env/test.travis.env test.env make test-coverage - codecov + codecov --token="${{ secrets.CODECOV_TOKEN }}" + - name: Cleanup + run: | + docker compose down diff --git a/Makefile b/Makefile index 0e3ad8c5..3eebfda6 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ setup-database: test-coverage: # Set up travis user in mongo @echo "Run tests for $(TESTS)" - PYTHONPATH=.:lib:test pytest --cov-report=xml --cov lib/execution_engine2/ --verbose $(TESTS) + PYTHONPATH=.:lib:test pytest --cov-report=xml --cov-report=term --cov lib/execution_engine2/ --verbose $(TESTS) build-condor-test-image: cd test/dockerfiles/condor && echo `pwd` && docker build -f Dockerfile . -t $(CONDOR_DOCKER_IMAGE_TAG_NAME) diff --git a/docker-compose.yml b/docker-compose.yml index d94790a4..996708d3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,57 +2,58 @@ version: "3.1" services: + # For Local Dev # Requires a ` docker build . -t execution_engine2:test ` # Requires a ` make database ` - ee2: - image: execution_engine2:test - command: - - "-poll" - - "-template" - - "/kb/module/build/templates/condor_config.templ:/etc/condor/condor_config" - - "-template" - - "/kb/module/test/deploy.cfg:/kb/module/deploy.cfg" - - "-timeout" - - "120s" - - "-wait" - - "tcp://mongodb:27017" - - "-stdout" - - "/kb/deployment/jettybase/logs/request.log" - - "./scripts/entrypoint.sh" - entrypoint: [ "dockerize" ] - depends_on: ["mongodb","condor"] - environment: - - POOL_PASSWORD=weakpassword - env_file: test/deploy.cfg - volumes: - - ./:/ee2 - - ee2_with_ssh: - image: execution_engine2:test - command: - - "-poll" - - "-template" - - "/kb/module/build/templates/condor_config.templ:/etc/condor/condor_config" - - "-template" - - "/kb/module/build/templates/deploy.docker.cfg.templ:/kb/module/deploy.cfg" - - "-timeout" - - "120s" - - "-wait" - - "tcp://mongodb:27017" - - "-stdout" - - "/kb/deployment/jettybase/logs/request.log" - - "./scripts/entrypoint.sh" - entrypoint: [ "dockerize" ] - depends_on: ["mongodb","condor"] - environment: - - POOL_PASSWORD=weakpassword - - LOCAL_DEV=1 - - KB_DEPLOYMENT_CONFIG=/kb/module/deploy.cfg - env_file: test/deploy.cfg - ports: ["23:22","5678:5678"] - volumes: - - ./:/ee2 - - /Users:/Users +# ee2: +# image: execution_engine2:test +# command: +# - "-poll" +# - "-template" +# - "/kb/module/build/templates/condor_config.templ:/etc/condor/condor_config" +# - "-template" +# - "/kb/module/test/deploy.cfg:/kb/module/deploy.cfg" +# - "-timeout" +# - "120s" +# - "-wait" +# - "tcp://mongodb:27017" +# - "-stdout" +# - "/kb/deployment/jettybase/logs/request.log" +# - "./scripts/entrypoint.sh" +# entrypoint: [ "dockerize" ] +# depends_on: ["mongodb","condor"] +# environment: +# - POOL_PASSWORD=weakpassword +# env_file: test/deploy.cfg +# volumes: +# - ./:/ee2 +# +# ee2_with_ssh: +# image: execution_engine2:test +# command: +# - "-poll" +# - "-template" +# - "/kb/module/build/templates/condor_config.templ:/etc/condor/condor_config" +# - "-template" +# - "/kb/module/build/templates/deploy.docker.cfg.templ:/kb/module/deploy.cfg" +# - "-timeout" +# - "120s" +# - "-wait" +# - "tcp://mongodb:27017" +# - "-stdout" +# - "/kb/deployment/jettybase/logs/request.log" +# - "./scripts/entrypoint.sh" +# entrypoint: [ "dockerize" ] +# depends_on: ["mongodb","condor"] +# environment: +# - POOL_PASSWORD=weakpassword +# - LOCAL_DEV=1 +# - KB_DEPLOYMENT_CONFIG=/kb/module/deploy.cfg +# env_file: test/deploy.cfg +# ports: ["23:22","5678:5678"] +# volumes: +# - ./:/ee2 +# - /Users:/Users @@ -146,13 +147,15 @@ services: ZOOKEEPER_SYNC_LIMIT: 2docker-compose rm ZOOKEEPER_SERVERS: zookeeper:12888:13888 + mongodb: - image: mongo:7.0 + image: mongo:${MONGO_VERSION:-7.0} # Use 7.0 as the default if MONGO_VERSION is not set environment: - # provide your credentials here - MONGO_INITDB_ROOT_USERNAME=travis - MONGO_INITDB_ROOT_PASSWORD=travis - MONGO_INITDB_DATABASE=ee2 - ports: ["27018:27017","27017:27017"] + ports: + - "27018:27017" + - "27017:27017" volumes: - - "./test/dockerfiles/mongo/docker-entrypoint-initdb.d/:/docker-entrypoint-initdb.d/" + - ${INIT_PATH:-./test/dockerfiles/mongo/docker-entrypoint-initdb.d-7.0/}:/docker-entrypoint-initdb.d/ diff --git a/test/dockerfiles/mongo/docker-entrypoint-initdb.d/mongo-init.js b/test/dockerfiles/mongo/docker-entrypoint-initdb.d-3.6/mongo-init.js similarity index 68% rename from test/dockerfiles/mongo/docker-entrypoint-initdb.d/mongo-init.js rename to test/dockerfiles/mongo/docker-entrypoint-initdb.d-3.6/mongo-init.js index 280adc77..c9e30a38 100755 --- a/test/dockerfiles/mongo/docker-entrypoint-initdb.d/mongo-init.js +++ b/test/dockerfiles/mongo/docker-entrypoint-initdb.d-3.6/mongo-init.js @@ -1,10 +1,6 @@ -print("Adding travis username to ee2 database") - -// db.auth('travis', 'travis') This no longer works on Mongo7 - - +print("Adding travis username to ee2 database for mongo 3.6") +db.auth('travis', 'travis') db = db.getSiblingDB('ee2') - db.createUser( { user: "travis", @@ -16,4 +12,4 @@ db.createUser( } ] } -); +); \ No newline at end of file diff --git a/test/dockerfiles/mongo/docker-entrypoint-initdb.d-7.0/mongo-init.js b/test/dockerfiles/mongo/docker-entrypoint-initdb.d-7.0/mongo-init.js new file mode 100755 index 00000000..72980892 --- /dev/null +++ b/test/dockerfiles/mongo/docker-entrypoint-initdb.d-7.0/mongo-init.js @@ -0,0 +1,14 @@ +print("Adding travis username to ee2 database for mongo 7.0") +db = db.getSiblingDB('ee2') +db.createUser( + { + user: "travis", + pwd: "travis", + roles: [ + { + role: "dbOwner", + db: "ee2" + } + ] + } +); \ No newline at end of file