diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac24766afbb..ea53f916144 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -390,10 +390,17 @@ jobs: upgrade: needs: [publish] - name: Upgrade from latest release + name: Upgrade from ${{ matrix.version }} runs-on: ubuntu-22.04 + timeout-minutes: 60 + if: ${{ github.event_name != 'pull_request' }} + strategy: + fail-fast: false + matrix: + version: [ '4.2.4', 'latest' ] + steps: - name: Configure AWS credentials Public if: ${{ env.INTERNAL_CONTRIBUTOR }} @@ -413,6 +420,7 @@ jobs: - name: Set ENV run: | echo "BUILDS_SERVER=$STAGING_SERVER" >> $GITHUB_ENV + echo "BASE_VERSION=${{ matrix.version }}" >> $GITHUB_ENV - run: npm ci - name: Create logs directory run: mkdir tests/logs @@ -422,7 +430,7 @@ jobs: - name: Archive Results uses: actions/upload-artifact@v4 with: - name: Upgrade + name: upgrade-${{ matrix.version }} path: | allure-results allure-report diff --git a/ddocs/.eslintrc b/ddocs/.eslintrc index fcdea031c61..c4d5c126164 100644 --- a/ddocs/.eslintrc +++ b/ddocs/.eslintrc @@ -7,6 +7,6 @@ "no-var": "off" }, "parserOptions": { - "ecmaVersion": 6, + "ecmaVersion": 5 } } diff --git a/ddocs/users-meta-db/users-meta/views/device_by_user/map.js b/ddocs/users-meta-db/users-meta/views/device_by_user/map.js index 425d19ebc7d..3edc3071c69 100644 --- a/ddocs/users-meta-db/users-meta/views/device_by_user/map.js +++ b/ddocs/users-meta-db/users-meta/views/device_by_user/map.js @@ -8,9 +8,12 @@ function(doc) { doc.metadata.month && doc.metadata.day ) { - const pad = number => number.toString().padStart(2, '0'); + var pad = function (number) { + return number.toString().padStart(2, '0'); + }; + emit([doc.metadata.user, doc.metadata.deviceId], { - date: `${doc.metadata.year}-${pad(doc.metadata.month)}-${pad(doc.metadata.day)}`, + date: doc.metadata.year + '-' + pad(doc.metadata.month) + '-' + pad(doc.metadata.day), id: doc._id, device: { userAgent: doc.device && doc.device.userAgent, diff --git a/ddocs/users-meta-db/users-meta/views/device_by_user/reduce.js b/ddocs/users-meta-db/users-meta/views/device_by_user/reduce.js index b84a11d566e..944557e9601 100644 --- a/ddocs/users-meta-db/users-meta/views/device_by_user/reduce.js +++ b/ddocs/users-meta-db/users-meta/views/device_by_user/reduce.js @@ -1,6 +1,6 @@ function (keys, values) { - let latest = { date: '1970-01-01' }; - values.forEach(function (value) { + var latest = { date: '1970-01-01' }; + values.forEach(function(value) { if (value.date > latest.date) { latest = value; } diff --git a/package-lock.json b/package-lock.json index eb47763aac7..14b6e3de749 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "medic", - "version": "4.8.0", + "version": "4.8.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "medic", - "version": "4.8.0", + "version": "4.8.1", "hasInstallScript": true, "license": "AGPL-3.0-only", "workspaces": [ diff --git a/package.json b/package.json index e245075f6b2..f5707fe498c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "medic", - "version": "4.8.0", + "version": "4.8.1", "private": true, "license": "AGPL-3.0-only", "repository": { diff --git a/tests/e2e/upgrade/upgrade.wdio-spec.js b/tests/e2e/upgrade/upgrade.wdio-spec.js index e2fb523edfc..8fa338c48fa 100644 --- a/tests/e2e/upgrade/upgrade.wdio-spec.js +++ b/tests/e2e/upgrade/upgrade.wdio-spec.js @@ -1,6 +1,6 @@ const utils = require('@utils'); -const { BRANCH, TAG } = process.env; +const { BRANCH, TAG, BASE_VERSION } = process.env; const loginPage = require('@page-objects/default/login/login.wdio.page'); const upgradePage = require('@page-objects/upgrade/upgrade.wdio.page'); const commonPage = require('@page-objects/default/common/common.wdio.page'); @@ -11,6 +11,8 @@ const version = require('../../../scripts/build/versions'); const dataFactory = require('@factories/cht/generate'); const semver = require('semver'); +const testFrontend = BASE_VERSION === 'latest'; + const docs = dataFactory.createHierarchy({ name: 'offlineupgrade', user: true, @@ -52,8 +54,12 @@ describe('Performing an upgrade', () => { await utils.saveDocs([...docs.places, ...docs.clinics, ...docs.persons, ...docs.reports]); await utils.createUsers([docs.user]); - await loginPage.login(docs.user); - await commonPage.logout(); + if (testFrontend) { + // a variety of selectors that we use in e2e tests to interact with webapp + // are not compatible with older versions of the app. + await loginPage.login(docs.user); + await commonPage.logout(); + } await loginPage.cookieLogin({ username: constants.USERNAME, @@ -72,6 +78,10 @@ describe('Performing an upgrade', () => { }); it('should have valid semver after installing', async () => { + if (!testFrontend) { + return; + } + const deployInfo = await utils.request({ path: '/api/deploy-info' }); expect(semver.valid(deployInfo.version)).to.be.ok; }); @@ -117,6 +127,10 @@ describe('Performing an upgrade', () => { state: 'finalized', }); + if (!testFrontend) { + return; + } + await adminPage.logout(); await loginPage.login(docs.user); await commonPage.sync(true); diff --git a/tests/e2e/upgrade/wdio.conf.js b/tests/e2e/upgrade/wdio.conf.js index c00010a10a0..ec7bf801fce 100644 --- a/tests/e2e/upgrade/wdio.conf.js +++ b/tests/e2e/upgrade/wdio.conf.js @@ -13,7 +13,7 @@ const rpn = require('request-promise-native'); const utils = require('@utils'); const wdioBaseConfig = require('../../wdio.conf'); -const { MARKET_URL_READ, STAGING_SERVER, HAPROXY_PORT } = process.env; +const { MARKET_URL_READ, STAGING_SERVER, HAPROXY_PORT, BASE_VERSION } = process.env; const CHT_COMPOSE_PROJECT_NAME = 'cht-upgrade'; const UPGRADE_SERVICE_DOCKER_COMPOSE_FOLDER = utils.makeTempDir('upgrade-service-'); @@ -28,7 +28,11 @@ const getUpgradeServiceDockerCompose = async () => { await fs.promises.writeFile(UPGRADE_SERVICE_DC, contents); }; -const getLatestRelease = async () => { +const getRelease = async () => { + if (BASE_VERSION !== 'latest') { + return `medic:medic:${BASE_VERSION}`; + } + const url = `${MARKET_URL_READ}/${STAGING_SERVER}/_design/builds/_view/releases`; const query = { startKey: ['release', 'medic', 'medic', {}], @@ -43,9 +47,9 @@ const getLatestRelease = async () => { }; const getMainCHTDockerCompose = async () => { - const latestRelease = await getLatestRelease(); + const release = await getRelease(); for (const composeFile of COMPOSE_FILES) { - const composeFileUrl = `${MARKET_URL_READ}/${STAGING_SERVER}/${latestRelease}/docker-compose/${composeFile}.yml`; + const composeFileUrl = `${MARKET_URL_READ}/${STAGING_SERVER}/${release}/docker-compose/${composeFile}.yml`; const contents = await rpn.get(composeFileUrl); const filePath = path.join(CHT_DOCKER_COMPOSE_FOLDER, `${composeFile}.yml`); await fs.promises.writeFile(filePath, contents); diff --git a/tests/factories/cht/reports/pregnancy.js b/tests/factories/cht/reports/pregnancy.js index e719d218fa9..86c2d10abb1 100644 --- a/tests/factories/cht/reports/pregnancy.js +++ b/tests/factories/cht/reports/pregnancy.js @@ -18,7 +18,7 @@ const defaultSubmitter = { }; const nextANCVisit = moment().add(2, 'day'); -const lmp = moment().subtract(3, 'months'); +const lmp = moment().subtract(90, 'days'); const defaultFields = { 'inputs': { diff --git a/tests/integration/couchdb/couch_chttpd.spec.js b/tests/integration/couchdb/couch_chttpd.spec.js index 54e1315fdb1..df2aa2ebc5f 100644 --- a/tests/integration/couchdb/couch_chttpd.spec.js +++ b/tests/integration/couchdb/couch_chttpd.spec.js @@ -21,8 +21,13 @@ const startContainer = async (useAuthentication) => { if (useAuthentication) { env.COUCH_AUTH = `${constants.USERNAME}:${constants.PASSWORD}`; } - return await runDockerCommand('docker-compose', ['up', '--build', '--force-recreate'], env); + await runDockerCommand('docker-compose', ['up', '--build', '--force-recreate'], env); }; + +const stopContainer = async () => { + await runDockerCommand('docker-compose', ['down', '--remove-orphans']); +}; + const getLogs = async () => { const containerName = (await runDockerCommand('docker-compose', ['ps', '-q', '-a']))[0]; const logs = await runDockerCommand('docker', ['logs', containerName]); @@ -46,6 +51,10 @@ const expectCorrectMetadata = (metadata) => { }; describe('accessing couch clustering endpoint', () => { + afterEach(async () => { + await stopContainer(); + }); + it('should block unauthenticated access through the host network', async () => { await expect( utils.request({ uri: `https://${constants.API_HOST}/_node/_local/_dbs/${constants.DB_NAME}`, noAuth: true }) diff --git a/tests/integration/couchdb/couch_httpd_script/docker-compose.yml b/tests/integration/couchdb/couch_httpd_script/docker-compose.yml index 4b65b5988d7..d9e6dd650c1 100644 --- a/tests/integration/couchdb/couch_httpd_script/docker-compose.yml +++ b/tests/integration/couchdb/couch_httpd_script/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3' - services: chttpd_call: build: . @@ -11,3 +9,4 @@ services: networks: net: name: cht-net-e2e + external: true