Add item diff page #2343
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
merge_group: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
jobs: | |
build-node: | |
name: Build / Node ${{ matrix.node }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node: [ 18, 20, 21 ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node }} | |
cache: npm | |
- name: Install latest npm | |
run: | | |
npm install --global npm@latest | |
npm -v | |
- name: Install dependencies | |
run: npm ci | |
- name: Cache turbo | |
uses: actions/cache@v3 | |
with: | |
path: ./node_modules/.cache/turbo | |
key: turbo-cache-build-${{ runner.os }}-${{ github.sha }} | |
restore-keys: | | |
turbo-cache-build-${{ runner.os }}- | |
- name: Run Build | |
run: npm run build | |
build-docker: | |
name: Build / Docker / ${{ matrix.target }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: [ web, worker, legacy-importer, database-migration, e2e ] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build the Docker image | |
uses: docker/[email protected] | |
with: | |
files: | | |
./docker-compose.yml | |
./docker-compose.importer.yml | |
./docker-compose.e2e.yml | |
targets: ${{ matrix.target }} | |
set: | | |
*.output=type=docker | |
*.cache-from=type=gha,scope=build-${{ matrix.target }} | |
*.cache-to=type=gha,scope=build-${{ matrix.target }},mode=max | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push image | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository }}/${{ matrix.target }} | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
VERSION=ci-run-${{ github.run_id }} | |
docker tag gw2treasures/${{ matrix.target }} $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION | |
test-compose: | |
name: Test / docker compose | |
runs-on: ubuntu-latest | |
needs: build-docker | |
steps: | |
- name: Add hosts | |
run: sudo echo "127.0.0.1 en.gw2treasures.localhost" | sudo tee -a /etc/hosts | |
- uses: actions/checkout@v4 | |
- name: Pull docker images | |
run: | | |
DOCKER_PREFIX=ghcr.io/${{ github.repository }} | |
DOCKER_PREFIX=$(echo $DOCKER_PREFIX | tr '[A-Z]' '[a-z]') | |
VERSION=ci-run-${{ github.run_id }} | |
docker pull $DOCKER_PREFIX/web:$VERSION | |
docker pull $DOCKER_PREFIX/worker:$VERSION | |
docker pull $DOCKER_PREFIX/legacy-importer:$VERSION | |
docker pull $DOCKER_PREFIX/database-migration:$VERSION | |
docker tag $DOCKER_PREFIX/web:$VERSION gw2treasures/web | |
docker tag $DOCKER_PREFIX/worker:$VERSION gw2treasures/worker | |
docker tag $DOCKER_PREFIX/legacy-importer:$VERSION gw2treasures/legacy-importer | |
docker tag $DOCKER_PREFIX/database-migration:$VERSION gw2treasures/database-migration | |
- name: Start docker compose | |
run: docker compose up -d | |
- name: Wait 30s | |
run: sleep 30 | |
- run: docker compose ps -a | |
- run: docker compose logs | |
- name: Verify docker containers are running | |
run: docker inspect --format "{{.ID}} {{.Name}} {{.State.Status}} {{.RestartCount}}" $(docker compose ps -aq) | node .github/actions/docker-compose-status.js | |
- run: curl --fail-with-body http://en.gw2treasures.localhost:3000/ | |
- name: Stop docker compose | |
run: docker compose down | |
test-kubernetes: | |
name: Test / kubernetes | |
runs-on: ubuntu-latest | |
needs: build-docker | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: nolar/setup-k3d-k3s@v1 | |
with: | |
version: v1.26 | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Pull docker images | |
run: | | |
DOCKER_PREFIX=ghcr.io/${{ github.repository }} | |
DOCKER_PREFIX=$(echo $DOCKER_PREFIX | tr '[A-Z]' '[a-z]') | |
VERSION=ci-run-${{ github.run_id }} | |
docker pull $DOCKER_PREFIX/web:$VERSION | |
docker pull $DOCKER_PREFIX/worker:$VERSION | |
docker pull $DOCKER_PREFIX/legacy-importer:$VERSION | |
docker pull $DOCKER_PREFIX/database-migration:$VERSION | |
docker tag $DOCKER_PREFIX/web:$VERSION gw2treasures/web | |
docker tag $DOCKER_PREFIX/worker:$VERSION gw2treasures/worker | |
docker tag $DOCKER_PREFIX/legacy-importer:$VERSION gw2treasures/legacy-importer | |
docker tag $DOCKER_PREFIX/database-migration:$VERSION gw2treasures/database-migration | |
- name: Import images into k3d | |
run: k3d image import gw2treasures/web gw2treasures/worker gw2treasures/legacy-importer gw2treasures/database-migration | |
- run: kubectl apply -k kubernetes/local | |
- run: kubectl rollout status deployment database next next-worker -n gw2treasures --timeout=180s | |
- run: kubectl get deployment -n gw2treasures | |
if: success() || failure() | |
- run: kubectl get job -n gw2treasures | |
if: success() || failure() | |
- run: kubectl logs -l app.kubernetes.io/part-of=gw2treasures -n gw2treasures --all-containers --ignore-errors | |
if: failure() || runner.debug == '1' | |
test-e2e: | |
name: Test / e2e | |
runs-on: ubuntu-latest | |
needs: build-docker | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Pull docker images | |
run: | | |
DOCKER_PREFIX=ghcr.io/${{ github.repository }} | |
DOCKER_PREFIX=$(echo $DOCKER_PREFIX | tr '[A-Z]' '[a-z]') | |
VERSION=ci-run-${{ github.run_id }} | |
docker pull $DOCKER_PREFIX/web:$VERSION | |
docker pull $DOCKER_PREFIX/worker:$VERSION | |
docker pull $DOCKER_PREFIX/legacy-importer:$VERSION | |
docker pull $DOCKER_PREFIX/database-migration:$VERSION | |
docker pull $DOCKER_PREFIX/e2e:$VERSION | |
docker tag $DOCKER_PREFIX/web:$VERSION gw2treasures/web | |
docker tag $DOCKER_PREFIX/worker:$VERSION gw2treasures/worker | |
docker tag $DOCKER_PREFIX/legacy-importer:$VERSION gw2treasures/legacy-importer | |
docker tag $DOCKER_PREFIX/database-migration:$VERSION gw2treasures/database-migration | |
docker tag $DOCKER_PREFIX/e2e:$VERSION gw2treasures/e2e | |
- name: Start docker compose | |
run: docker compose -f docker-compose.yml -f docker-compose.e2e.yml up -d web database database-migration | |
- name: Wait for containers to be up | |
run: sleep 30 | |
- name: Run e2e tests | |
run: docker compose -f docker-compose.yml -f docker-compose.e2e.yml up e2e --no-log-prefix --exit-code-from e2e | |
- name: Stop docker compose | |
run: docker compose down | |
test-unit: | |
name: Test / Unit | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: npm | |
- name: Install latest npm | |
run: | | |
npm install --global npm@latest | |
npm -v | |
- name: Install dependencies | |
run: npm ci | |
- name: Cache turbo | |
uses: actions/cache@v3 | |
with: | |
path: ./node_modules/.cache/turbo | |
key: turbo-cache-test-${{ runner.os }}-${{ github.sha }} | |
restore-keys: | | |
turbo-cache-test-${{ runner.os }}- | |
- name: Run Test | |
run: npm run test | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: npm | |
- name: Install latest npm | |
run: | | |
npm install --global npm@latest | |
npm -v | |
- name: Install dependencies | |
run: npm ci | |
- name: Cache turbo | |
uses: actions/cache@v3 | |
with: | |
path: ./node_modules/.cache/turbo | |
key: turbo-cache-lint-${{ runner.os }}-${{ github.sha }} | |
restore-keys: | | |
turbo-cache-lint-${{ runner.os }}- | |
- name: Run Lint | |
run: npm run lint | |
renovate: | |
name: Validate renovate config | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install renovate | |
run: npm i -g renovate | |
- name: Validate config | |
run: renovate-config-validator --strict | |
success: | |
name: Success | |
needs: [test-compose, test-kubernetes, test-e2e, test-unit, build-node, lint, renovate] | |
runs-on: ubuntu-latest | |
if: always() | |
steps: | |
- name: Check job status | |
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}' | |
- name: Success | |
run: exit 0 | |
publish-docker: | |
name: Publish / Docker / ${{ matrix.target }} | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
needs: [success] | |
strategy: | |
matrix: | |
target: [ web, worker, legacy-importer, database-migration ] | |
steps: | |
- name: Pull docker images | |
run: | | |
DOCKER_PREFIX=ghcr.io/${{ github.repository }} | |
DOCKER_PREFIX=$(echo $DOCKER_PREFIX | tr '[A-Z]' '[a-z]') | |
VERSION=ci-run-${{ github.run_id }} | |
docker pull $DOCKER_PREFIX/${{ matrix.target }}:$VERSION | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push image | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository }}/${{ matrix.target }} | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
# Strip git ref prefix from version | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# Strip "v" prefix from tag name | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
# Use Docker `latest` tag convention | |
[ "$VERSION" == "main" ] && VERSION=latest | |
CI_TAG=ci-run-${{ github.run_id }} | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
docker tag $IMAGE_ID:$CI_TAG $IMAGE_ID:$VERSION | |
docker push $IMAGE_ID:$VERSION | |
publish-npm: | |
name: Publish / npm / ${{ matrix.target }} | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
needs: [success] | |
permissions: | |
contents: read | |
id-token: write | |
strategy: | |
matrix: | |
target: [ ui, icons ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: npm | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install latest npm | |
run: | | |
npm install --global npm@latest | |
npm -v | |
- name: Install dependencies | |
run: npm ci | |
- name: Run Publish | |
run: npm run publish-package -- --filter=${{ matrix.target }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
NPM_CONFIG_PROVENANCE: true |