From 4851fc88b78df7f22436b27d3a69ccb88fc6d79d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halvard=20M=C3=B8rstad?= Date: Wed, 24 Apr 2024 17:08:18 +0200 Subject: [PATCH] Updated CI --- .github/workflows/ci.yml | 107 ++++++++++----------- .github/workflows/publish-to-nest.land.yml | 23 ----- .github/workflows/publish.yml | 29 ++++++ .github/workflows/wait-for-mysql.sh | 11 --- 4 files changed, 80 insertions(+), 90 deletions(-) delete mode 100644 .github/workflows/publish-to-nest.land.yml create mode 100644 .github/workflows/publish.yml delete mode 100755 .github/workflows/wait-for-mysql.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3860f8a..96d79be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,69 +1,64 @@ name: ci -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: + branches: + - main + +env: + DENO_VERSION: vx.x.x jobs: - fmt: + check: + name: Check format and lint + runs-on: ubuntu-latest + + steps: + - name: Clone repo + uses: actions/checkout@v4 + + - name: Install deno + uses: denoland/setup-deno@v1 + with: + deno-version: ${{env.DENO_VERSION}} + + - name: Check + run: deno task check + + tests: + name: Run tests runs-on: ubuntu-latest - continue-on-error: true + steps: - - uses: actions/checkout@v1 - - name: Install Deno 1.x + - name: Clone repo + uses: actions/checkout@v4 + + - name: Install deno uses: denoland/setup-deno@v1 with: - deno-version: v1.x - - name: Check fmt - run: deno fmt --check - test: + deno-version: ${{env.DENO_VERSION}} + + - name: Test + run: deno task test:ga + + publish: runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - DENO_VERSION: - - v1.x - DB_VERSION: - - mysql:5.5 - - mysql:5.6 - - mysql:5.7 - - mysql:8 - - mysql:latest - - mariadb:5.5 - - mariadb:10.0 - - mariadb:10.1 - - mariadb:10.2 - - mariadb:10.3 - - mariadb:10.4 -# - mariadb:latest + + permissions: + contents: read + id-token: write steps: - - uses: actions/checkout@v1 - - name: Install Deno ${{ matrix.DENO_VERSION }} + - name: Checkout + uses: actions/checkout@v4 + + - name: Install deno uses: denoland/setup-deno@v1 with: - deno-version: ${{ matrix.DENO_VERSION }} - - name: Show Deno version - run: deno --version - - name: Start ${{ matrix.DB_VERSION }} - run: | - sudo mkdir -p /var/run/mysqld/tmp - sudo chmod -R 777 /var/run/mysqld - docker container run --name mysql --rm -d -p 3306:3306 \ - -v /var/run/mysqld:/var/run/mysqld \ - -v /var/run/mysqld/tmp:/tmp \ - -e MYSQL_ROOT_PASSWORD=root \ - ${{ matrix.DB_VERSION }} - ./.github/workflows/wait-for-mysql.sh - - name: Run tests (TCP) - run: | - deno test --allow-env --allow-net=127.0.0.1:3306 ./test.ts - - name: Run tests (--unstable) (UNIX domain socket) - run: | - SOCKPATH=/var/run/mysqld/mysqld.sock - if [[ "${{ matrix.DB_VERSION }}" == "mysql:5.5" ]]; then - SOCKPATH=/var/run/mysqld/tmp/mysql.sock - fi - echo "DROP USER 'root'@'localhost';" | docker exec -i mysql mysql -proot - DB_SOCKPATH=$SOCKPATH TEST_METHODS=unix \ - deno test --unstable --allow-env \ - --allow-read=/var/run/mysqld/ --allow-write=/var/run/mysqld/ \ - ./test.ts + deno-version: ${{env.DENO_VERSION}} + + - name: Publish (dry run) + run: deno publish --dry-run diff --git a/.github/workflows/publish-to-nest.land.yml b/.github/workflows/publish-to-nest.land.yml deleted file mode 100644 index 87cc581..0000000 --- a/.github/workflows/publish-to-nest.land.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: "publish current release to https://nest.land" - -on: - release: - types: - - published - -jobs: - publishToNestDotLand: - runs-on: ubuntu-latest - - steps: - - name: Setup repo - uses: actions/checkout@v2 - - - name: "setup" # check: https://github.com/actions/virtual-environments/issues/1777 - uses: denolib/setup-deno@v2 - with: - deno-version: v1.4.6 - - - name: "check nest.land" - run: | - deno run --allow-net --allow-read --allow-run https://deno.land/x/cicd/publish-on-nest.land.ts ${{ secrets.GITHUB_TOKEN }} ${{ secrets.NESTAPIKEY }} ${{ github.repository }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..58837de --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,29 @@ +name: Publish + +on: + release: + types: [published] + +env: + DENO_VERSION: vx.x.x + +jobs: + publish: + runs-on: ubuntu-latest + + permissions: + contents: read + id-token: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Deno + uses: denoland/setup-deno@v1 + with: + deno-version: ${{env.DENO_VERSION}} + + - name: Publish + if: github.event_name == 'release' + run: deno publish diff --git a/.github/workflows/wait-for-mysql.sh b/.github/workflows/wait-for-mysql.sh deleted file mode 100755 index 13302dd..0000000 --- a/.github/workflows/wait-for-mysql.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -echo "Waiting for MySQL" -for i in `seq 1 30`; -do - echo '\q' | mysql -h 127.0.0.1 -uroot --password=root -P 3306 && exit 0 - >&2 echo "MySQL is waking up" - sleep 1 -done - -echo "Failed waiting for MySQL" && exit 1