From f63ac385603be05d55146f92d791995ea132f889 Mon Sep 17 00:00:00 2001 From: Matti Schneider Date: Thu, 18 Aug 2022 16:25:13 +0200 Subject: [PATCH 1/9] Update CI Windows package manager --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0efec242b..142227d15 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,7 @@ jobs: mongodb-version: 4.4 - name: Install and Start MongoDB (windows) if: matrix.operating_system == 'windows-2019' - uses: crazy-max/ghaction-chocolatey@v1.6.0 + uses: crazy-max/ghaction-chocolatey@v2 with: args: install mongodb - run: npm ci From 62cdb2a161c0c82ad34c2dcc264cc163e4134995 Mon Sep 17 00:00:00 2001 From: Matti Schneider Date: Thu, 18 Aug 2022 16:41:25 +0200 Subject: [PATCH 2/9] Specify CI version of MongoDB Allow downgrade of MongoDB on Windows --- .github/workflows/test.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 142227d15..ae538bde0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,6 +17,9 @@ jobs: runs-on: ${{ matrix.operating_system }} + env: + MONGODB_VERSION: 4.4 + steps: - run: | git config --global user.name 'Open Terms Archive Bot' @@ -30,12 +33,12 @@ jobs: if: matrix.operating_system == 'ubuntu-latest' uses: supercharge/mongodb-github-action@1.7.0 with: - mongodb-version: 4.4 + mongodb-version: ${{ env.MONGODB_VERSION }} - name: Install and Start MongoDB (windows) if: matrix.operating_system == 'windows-2019' uses: crazy-max/ghaction-chocolatey@v2 with: - args: install mongodb + args: install mongodb --force --version=${{ env.MONGODB_VERSION }} - run: npm ci - run: npm test From ac559706e3d07bb42587191e2131d499af2ec536 Mon Sep 17 00:00:00 2001 From: Matti Schneider Date: Thu, 18 Aug 2022 16:58:01 +0200 Subject: [PATCH 3/9] Use bundled MongoDB in CI --- .github/workflows/test.yml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ae538bde0..3b9912258 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,9 +17,6 @@ jobs: runs-on: ${{ matrix.operating_system }} - env: - MONGODB_VERSION: 4.4 - steps: - run: | git config --global user.name 'Open Terms Archive Bot' @@ -29,16 +26,10 @@ jobs: - uses: actions/setup-node@v2 with: node-version: 16 - - name: Install and Start MongoDB (ubuntu) - if: matrix.operating_system == 'ubuntu-latest' - uses: supercharge/mongodb-github-action@1.7.0 - with: - mongodb-version: ${{ env.MONGODB_VERSION }} - - name: Install and Start MongoDB (windows) - if: matrix.operating_system == 'windows-2019' - uses: crazy-max/ghaction-chocolatey@v2 - with: - args: install mongodb --force --version=${{ env.MONGODB_VERSION }} + - name: Start MongoDB + run: | + mkdir /tmp/test-database + mongod --dbpath /tmp/test-database --fork --logpath /tmp/mongodb-log - run: npm ci - run: npm test From 47a10933acc57ac27bdb2ba69d2349bfa1ea071a Mon Sep 17 00:00:00 2001 From: Matti Schneider Date: Tue, 23 Aug 2022 17:08:00 +0200 Subject: [PATCH 4/9] Start MongoDB as a service in CI --- .github/workflows/test.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3b9912258..738a220d9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,6 +17,12 @@ jobs: runs-on: ${{ matrix.operating_system }} + services: + mongo: + image: mongo + ports: + - 27017:27017 + steps: - run: | git config --global user.name 'Open Terms Archive Bot' @@ -26,10 +32,6 @@ jobs: - uses: actions/setup-node@v2 with: node-version: 16 - - name: Start MongoDB - run: | - mkdir /tmp/test-database - mongod --dbpath /tmp/test-database --fork --logpath /tmp/mongodb-log - run: npm ci - run: npm test From 447e62177a0dbd4434df1c044c3b08175abd9546 Mon Sep 17 00:00:00 2001 From: Matti Schneider Date: Tue, 23 Aug 2022 17:08:10 +0200 Subject: [PATCH 5/9] Revert "Start MongoDB as a service in CI" Windows does not support container operations --- .github/workflows/test.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 738a220d9..3b9912258 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,12 +17,6 @@ jobs: runs-on: ${{ matrix.operating_system }} - services: - mongo: - image: mongo - ports: - - 27017:27017 - steps: - run: | git config --global user.name 'Open Terms Archive Bot' @@ -32,6 +26,10 @@ jobs: - uses: actions/setup-node@v2 with: node-version: 16 + - name: Start MongoDB + run: | + mkdir /tmp/test-database + mongod --dbpath /tmp/test-database --fork --logpath /tmp/mongodb-log - run: npm ci - run: npm test From 196b2bd2b7bffcd6a8b1acaad05b0c21b95239e6 Mon Sep 17 00:00:00 2001 From: Matti Schneider Date: Fri, 19 Aug 2022 13:49:02 +0200 Subject: [PATCH 6/9] Test on latest Windows version --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3b9912258..b4e0da608 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: test: strategy: matrix: - operating_system: [ ubuntu-latest, windows-2019 ] + operating_system: [ ubuntu-latest, windows-latest ] fail-fast: false # run tests on other operating systems even if one fails runs-on: ${{ matrix.operating_system }} @@ -36,7 +36,7 @@ jobs: validate_declarations: strategy: matrix: - operating_system: [ubuntu-latest, windows-2019] + operating_system: [ ubuntu-latest, windows-latest ] fail-fast: false # run tests on other operating systems even if one fails runs-on: ${{ matrix.operating_system }} From 24d32c5423b84c65d8ce3dd9f8f793d71d472aef Mon Sep 17 00:00:00 2001 From: Matti Schneider Date: Fri, 19 Aug 2022 15:01:54 +0200 Subject: [PATCH 7/9] Start pre-installed MongoDB service on Windows Instructions from https://github.com/actions/runner-images/issues/5949#issuecomment-1210885327 and https://github.com/actions/runner-images/issues/5949#issuecomment-1223808051 --- .github/workflows/test.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b4e0da608..925abb7ef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,13 +23,19 @@ jobs: git config --global user.email 'bot@opentermsarchive.org' git config --global core.autocrlf false - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: 16 - - name: Start MongoDB + - name: Start MongoDB (UNIX) + if: runner.os != 'Windows' run: | mkdir /tmp/test-database mongod --dbpath /tmp/test-database --fork --logpath /tmp/mongodb-log + - name: Start MongoDB (Windows) + if: runner.os == 'Windows' + run: | + Set-Service MongoDB -StartupType Automatic + Start-Service -Name MongoDB + - uses: actions/setup-node@v2 + with: + node-version: 16 - run: npm ci - run: npm test From 84a12273069e965b25954af08e3793699b8db953 Mon Sep 17 00:00:00 2001 From: Matti Schneider Date: Tue, 23 Aug 2022 11:58:57 +0200 Subject: [PATCH 8/9] Use sc.exe syntax to start MongoDB service Follow instructions in https://github.com/actions/runner-images/issues/5949#issuecomment-1223837948 --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 925abb7ef..51d4f1404 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,8 +31,8 @@ jobs: - name: Start MongoDB (Windows) if: runner.os == 'Windows' run: | - Set-Service MongoDB -StartupType Automatic - Start-Service -Name MongoDB + sc.exe config MongoDB start= auto + sc.exe start MongoDB - uses: actions/setup-node@v2 with: node-version: 16 From bde8325bcffc36e56422668edf7300531d4403f9 Mon Sep 17 00:00:00 2001 From: Matti Schneider Date: Wed, 24 Aug 2022 10:14:10 +0200 Subject: [PATCH 9/9] Improve syntax readability for MongoDB Windows CI Same failure rate (~10%) See https://github.com/actions/runner-images/issues/5949#issuecomment-1225522672 for a benchmark --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 51d4f1404..925abb7ef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,8 +31,8 @@ jobs: - name: Start MongoDB (Windows) if: runner.os == 'Windows' run: | - sc.exe config MongoDB start= auto - sc.exe start MongoDB + Set-Service MongoDB -StartupType Automatic + Start-Service -Name MongoDB - uses: actions/setup-node@v2 with: node-version: 16