diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8e58ac3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,64 @@ +name: CI +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + unit-test: + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 + with: + node-version: 20 + cache: npm + - run: npm ci + - run: npm test -- --runInBand + + shellcheck: + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + contents: read + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - name: bash syntax check + run: | + bash -n entrypoint.sh + bash -n tests/test-integration.sh + bash -n tests/test-streaming-real.sh + - name: Run ShellCheck + run: | + if ! command -v shellcheck >/dev/null; then + sudo apt-get update && sudo apt-get install -y shellcheck + fi + shellcheck -S warning entrypoint.sh tests/test-integration.sh tests/test-streaming-real.sh + + docker-build: + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + contents: read + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 + - uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5 + with: + context: . + file: ./Dockerfile + push: false + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index a651c9b..8491a7d 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -12,6 +12,8 @@ env: jobs: build-and-push: + # Forks share this file but must not push to the upstream image namespace. + if: github.repository == 'TiaraBasori/OpenCode2API' runs-on: ubuntu-latest permissions: contents: read