Skip to content

[WIP] Migrate from CirleCI to GitHub Actions #2

[WIP] Migrate from CirleCI to GitHub Actions

[WIP] Migrate from CirleCI to GitHub Actions #2

Workflow file for this run

name: CI
on:
push:
branches:
- master
- production
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run lint-js
run: yarn lint-js
- name: Run prettier check
run: yarn prettier-run
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run tests
run: yarn test --runInBand
python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'yarn'
- name: Install Python dependencies
run: pip install --user flake8
- name: Install Node dependencies
run: yarn install --frozen-lockfile
- name: Run Python tests
run: yarn test-python
- name: Run Python lint
run: yarn lint-python
typescript:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run TypeScript check
run: yarn ts
yarn_lock:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Test lockfile
run: yarn test-lockfile
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build project
run: |
yarn build:clean
yarn build
license-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Check licenses
run: yarn license-check
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: yarn docker:build --pull --build-arg build_url=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} --build-arg github_ref_name=${{ github.ref_name }}
- name: Test Docker image
run: |
cp .env.example .env
yarn docker:run:detached
# Wait up to 10 seconds that the server is launched.
timeout 10s sh <<'EOF'
while ! docker exec profiler-server curl -i --silent --show-error --fail http://localhost:8000/__version__ ; do
sleep 1
done
EOF
yarn docker:stop
- name: Save Docker image
run: docker save -o image.tar profiler-server:dev
# This makes it possible to load this image from subsequent jobs.
- name: Upload Docker image artifact
uses: actions/upload-artifact@v4
with:
name: docker-image
path: image.tar
retention-days: 1
# This job only runs on pushes to master/production branches, not on PRs.
docker-publish:
runs-on: ubuntu-latest
needs: docker
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/production')
steps:
- name: Download Docker image artifact
uses: actions/download-artifact@v4
with:
name: docker-image
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Load Docker image
run: docker load -i image.tar
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Publish Docker Image to Docker Hub
env:
IMAGE_NAME: mozilla/profiler-server
run: |
# Use both a version tag depending on the github's run number
# and a latest tag that's depending on the branch name.
# Please keep the version in sync with the version file generated in
# bin/generate-version-file.js.
IMAGE_VERSION_TAG="0.1.${{ github.run_number }}"
IMAGE_LATEST_TAG="${{ github.ref_name }}-latest"
docker tag profiler-server:dev $IMAGE_NAME:$IMAGE_LATEST_TAG
docker tag profiler-server:dev $IMAGE_NAME:$IMAGE_VERSION_TAG
docker push $IMAGE_NAME:$IMAGE_LATEST_TAG
docker push $IMAGE_NAME:$IMAGE_VERSION_TAG