diff --git a/.github/act/README.md b/.github/act/README.md index 152ae9cb..461fda74 100644 --- a/.github/act/README.md +++ b/.github/act/README.md @@ -12,7 +12,13 @@ docker pull ghcr.io/jefuller/artifact-server:latest docker run -d --name artifact-server -p 8082:8080 --add-host host.docker.internal:host-gateway -e AUTH_KEY=foo ghcr.io/jefuller/artifact-server:latest ``` -Run the following **from this directory** to make use of `.actrc` and proper working directoy. +Run the following **from this directory** to make use of `.actrc` and proper working directory. + +### Test Branch Test Suite + +```shell +act -W '.github/act/testSuite.yml' -e '.github/act/actBranchEvent.json' +``` ### Test Branch Push @@ -44,4 +50,4 @@ act -W '.github/act/multiRunnerTest.yml' -e '.github/act/actBranchEvent.json' ```shell act -W '.github/act/multiRunnerBakeTest.yml' -e '.github/act/actBranchEvent.json' -``` \ No newline at end of file +``` diff --git a/.github/act/testSuite.yml b/.github/act/testSuite.yml index 09ea7e06..92950232 100644 --- a/.github/act/testSuite.yml +++ b/.github/act/testSuite.yml @@ -7,19 +7,4 @@ on: jobs: test: - name: Run Tests - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v4 - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: '18.x' - cache: 'npm' - - name: Install dev dependencies - run: npm ci - - name: Build Backend - run: 'npm run build:backend' - - name: Test Backend - run: npm run test + uses: ./.github/workflows/testAndSanity.yml \ No newline at end of file diff --git a/.github/workflows/dependabotTest.yml b/.github/workflows/dependabotTest.yml index 684d6203..a4aec16b 100644 --- a/.github/workflows/dependabotTest.yml +++ b/.github/workflows/dependabotTest.yml @@ -11,24 +11,6 @@ on: jobs: test: - name: Run Tests and Build (sanity) + name: Tests / Build / Sanity Run if: github.actor == 'dependabot[bot]' - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v4 - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: '18.x' - cache: 'npm' - - name: Install dev dependencies - run: npm ci - - name: Build Backend - run: 'npm run build:backend' - - name: Test Backend - run: npm run test - - name: Install Docs Deps - run: npm run docs:install - - name: Build - run: npm run build + uses: ./.github/workflows/testAndSanity.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 5ceef444..9d4d9b11 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -12,23 +12,8 @@ on: jobs: test: - name: Run Tests - runs-on: ubuntu-latest if: contains(github.event.pull_request.labels.*.name, 'safe to test') - steps: - - name: Check out the repo - uses: actions/checkout@v4 - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: '18.x' - cache: 'npm' - - name: Install dev dependencies - run: npm ci - - name: Build Backend - run: 'npm run build:backend' - - name: Test Backend - run: npm run test + uses: ./.github/workflows/testAndSanity.yml release-snapshot: name: Release snapshot @@ -45,9 +30,6 @@ jobs: - dockerfile: ./Dockerfile suffix: '' platforms: 'linux/amd64,linux/arm64' -# - dockerfile: ./alpine.Dockerfile -# suffix: '-alpine' -# platforms: 'linux/amd64,linux/arm64' steps: - name: Set up QEMU uses: docker/setup-qemu-action@v3 diff --git a/.github/workflows/publishImage.yml b/.github/workflows/publishImage.yml index b77c2b4f..991f7dc4 100644 --- a/.github/workflows/publishImage.yml +++ b/.github/workflows/publishImage.yml @@ -20,23 +20,8 @@ on: jobs: test: - name: Run Tests if: github.event_name != 'pull_request' - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v4 - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: '18.x' - cache: 'npm' - - name: Install dev dependencies - run: npm ci - - name: Build Backend - run: 'npm run build:backend' - - name: Test Backend - run: npm run test + uses: ./.github/workflows/testAndSanity.yml push_to_registry: name: Build and push container images diff --git a/.github/workflows/testAndSanity.yml b/.github/workflows/testAndSanity.yml new file mode 100644 index 00000000..62d7e4a9 --- /dev/null +++ b/.github/workflows/testAndSanity.yml @@ -0,0 +1,57 @@ +name: Tests and Sanity Run + +on: + workflow_call: + inputs: + node-version: + description: "Node version" + required: false + default: '18.x' + type: string + +jobs: + test: + name: Tests / Build / Sanity Run + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + cache: 'npm' + + - name: Install dev dependencies + run: npm ci + - name: Test Backend + run: npm run test + + - name: Install Docs Deps + run: NODE_ENV=production npm run docs:install + - name: Build + run: NODE_ENV=production npm run build + + # remove modules that might include dev stuff + # so that in the next step we are sure that prod-only runs work correctly + - name: Install Prod Deps + run: | + rm -rf node_modules && \ + rm -rf docsite/node_modules && \ + NODE_ENV=production npm ci --omit=dev + + # run app for 10 seconds as sanity check to see if it errors for any reason + # easy testcase for missing packages and init errors + - name: Sanity Run + run: | + set +e + export NODE_ENV=production + timeout --preserve-status 10s node node_modules/.bin/tsx src/backend/index.ts + exitcode="$?" + if [[ "$exitcode" -eq 143 ]] || [[ "$exitcode" -eq 137 ]]; then + echo "App stayed up long enough and exited with expected status" + exit 0 + else + echo "App exited with unexpected code $exitcode" + exit "$exitcode" + fi