diff --git a/.github/workflows/migrations-check.yml b/.github/workflows/migrations-check.yml index 3929e7f10e6f..f3ac2222c577 100644 --- a/.github/workflows/migrations-check.yml +++ b/.github/workflows/migrations-check.yml @@ -17,11 +17,11 @@ jobs: python-version: [ 3.8 ] # 'pinned' is used to install the latest patch version of Django # within the global constraint i.e. Django==3.2.21 in current case - # because we have global constraint of Django<4.2 + # because we have global constraint of Django<4.2 django-version: ["pinned", "4.2"] mongo-version: ["4"] mysql-version: ["5.7", "8"] - # excluding mysql5.7 with Django 4.2 since Django 4.2 has + # excluding mysql5.7 with Django 4.2 since Django 4.2 has # dropped support for MySQL<8 exclude: - django-version: "4.2" @@ -120,7 +120,7 @@ jobs: ./manage.py lms migrate echo "Running the CMS migrations." ./manage.py cms migrate - + # This job aggregates test results. It's the required check for branch protection. # https://github.com/marketplace/actions/alls-green#why # https://github.com/orgs/community/discussions/33579 diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index c3b1086c20eb..051a4e326af5 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -10,7 +10,7 @@ jobs: run-tests: name: python-${{ matrix.python-version }},django-${{ matrix.django-version }},${{ matrix.shard_name }} if: (github.repository == 'edx/edx-platform-private') || (github.repository == 'openedx/edx-platform' && (startsWith(github.base_ref, 'open-release') == false)) - runs-on: [ edx-platform-runner ] + runs-on: ubuntu-latest strategy: matrix: python-version: @@ -18,52 +18,102 @@ jobs: django-version: - "pinned" - "4.2" + mongo-version: ["4"] + mysql-version: ["8"] # When updating the shards, remember to make the same changes in # .github/workflows/unit-tests-gh-hosted.yml shard_name: - "lms-1" - - "lms-2" - - "lms-3" - - "lms-4" - - "lms-5" - - "lms-6" - - "openedx-1-with-lms" - - "openedx-2-with-lms" - - "openedx-1-with-cms" - - "openedx-2-with-cms" - - "cms-1" - - "cms-2" - - "common-with-lms" - - "common-with-cms" - - "xmodule-with-lms" - - "xmodule-with-cms" +# - "lms-2" +# - "lms-3" +# - "lms-4" +# - "lms-5" +# - "lms-6" +# - "openedx-1-with-lms" +# - "openedx-2-with-lms" +# - "openedx-1-with-cms" +# - "openedx-2-with-cms" +# - "cms-1" +# - "cms-2" +# - "common-with-lms" +# - "common-with-cms" +# - "xmodule-with-lms" +# - "xmodule-with-cms" # We expect Django 4.0 to fail, so don't stop when it fails. continue-on-error: ${{ matrix.django-version == '4.0' }} - + services: + mongo: + image: mongo:${{ matrix.mongo-version }} + ports: + - 27017:27017 + # Note: Calling `mongo` here only works with mongo 4, in newer versions of mongo + # we'll have to use `mongosh` + options: >- + --health-cmd "mongo --quiet --eval 'db.runCommand(\"ping\")'" + --health-interval 10s + --health-timeout 5s + --health-retries 3 + mysql: + image: mysql:${{ matrix.mysql-version }} + ports: + - 3306:3306 + env: + MYSQL_DATABASE: "edxapp" + MYSQL_USER: "edxapp001" + MYSQL_PASSWORD: "password" + MYSQL_RANDOM_ROOT_PASSWORD: true + options: >- + --health-cmd "mysqladmin ping" + --health-interval 10s + --health-timeout 5s + --health-retries 3 steps: - - name: sync directory owner - run: sudo chown runner:runner -R .* +# - name: sync directory owner +# run: sudo chown runner:runner -R .* +# - name: Setup mongodb user +# run: | +# mongo edxapp --eval ' +# db.createUser( +# { +# user: "edxapp", +# pwd: "password", +# roles: [ +# { role: "readWrite", db: "edxapp" }, +# ] +# } +# ); +# ' +# +# - name: Verify mongo and mysql db credentials +# run: | +# mysql -h 127.0.0.1 -uedxapp001 -ppassword -e "select 1;" edxapp +# mongo --host 127.0.0.1 --username edxapp --password password --eval 'use edxapp; db.adminCommand("ping");' edxapp + + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} - name: checkout repo uses: actions/checkout@v3 - - name: start mongod server for tests + - name: Install system Packages run: | - sudo mkdir -p /data/db - sudo chmod -R a+rw /data/db - mongod & + sudo apt-get update + make ubuntu-requirements - name: install requirements run: | - sudo make test-requirements + make test-requirements if [[ "${{ matrix.django-version }}" != "pinned" ]]; then - sudo pip install "django~=${{ matrix.django-version }}.0" - sudo pip check # fail if this test-reqs/Django combination is broken + pip install "django~=${{ matrix.django-version }}.0" + pip check # fail if this test-reqs/Django combination is broken fi - name: list installed package versions run: | - sudo pip freeze + pip freeze - name: Setup and run tests uses: ./.github/actions/unit-tests @@ -95,7 +145,7 @@ jobs: jobs: ${{ toJSON(needs) }} compile-warnings-report: - runs-on: [ edx-platform-runner ] + runs-on: ubuntu-latest needs: [ run-tests ] steps: - name: sync directory owner