ci #642
This file contains hidden or 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 | |
| # See https://docs.docker.com/build/ci/github-actions/examples | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| DOCKER_BUILDKIT: 1 | |
| LLVM_VER: "20" | |
| # Uncomment to cap ninja parallelism (reduces peak memory for cold LLVM builds) | |
| # NINJA_MAX_JOBS: "2" | |
| on: | |
| schedule: | |
| - cron: "41 1 * * 1" | |
| push: | |
| branches: | |
| - "**" | |
| tags: | |
| - "v*.*.*" | |
| pull_request: | |
| branches: | |
| - "main" | |
| jobs: | |
| changes: | |
| # Detect whether build-relevant files changed. | |
| # Skipped for schedule and tag events -- those always build. | |
| if: >- | |
| github.event_name != 'schedule' | |
| && !startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| outputs: | |
| build: ${{ steps.filter.outputs.build }} | |
| steps: | |
| - | |
| name: Checkout | |
| uses: actions/checkout@v6 | |
| - | |
| name: Check changed paths | |
| uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| filters: | | |
| build: | |
| - 'Dockerfile' | |
| - 'Dockerfile.devtools' | |
| - 'build-llvm.sh' | |
| - 'docker-entrypoint.sh' | |
| - 'install-intel-ifx.sh' | |
| - 'patches' | |
| - 'patches/**' | |
| - '.dockerignore' | |
| - '.github/workflows/CI.yml' | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - | |
| name: Checkout | |
| uses: actions/checkout@v6 | |
| - | |
| name: Install hadolint | |
| run: | | |
| HADOLINT_VERSION=v2.14.0 | |
| curl -sL "https://github.com/hadolint/hadolint/releases/download/${HADOLINT_VERSION}/hadolint-Linux-x86_64" \ | |
| -o /usr/local/bin/hadolint | |
| chmod +x /usr/local/bin/hadolint | |
| - | |
| name: Install actionlint | |
| run: | | |
| bash <(curl -sL https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) | |
| mv actionlint /usr/local/bin/ | |
| - | |
| name: Run linters | |
| run: bash lint.sh --verbose | |
| - | |
| name: Run build script tests | |
| run: bash test-build-llvm.sh | |
| build-base: | |
| needs: [lint, changes] | |
| # Run when lint passed AND build-relevant files changed. | |
| # Always run for schedule and tag events (changes job is skipped). | |
| if: >- | |
| always() | |
| && needs.lint.result == 'success' | |
| && (needs.changes.result == 'skipped' | |
| || needs.changes.outputs.build == 'true') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - | |
| name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| - | |
| name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| # list of Docker images to use as base name for tags | |
| images: | | |
| paratools/salt-dev | |
| ghcr.io/paratoolsinc/salt-dev | |
| # generate Docker tags based on the following events/attributes | |
| tags: | | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=raw,value=latest-llvm-${{ env.LLVM_VER }},enable={{is_default_branch}} | |
| type=ref,event=branch | |
| type=ref,event=branch,suffix=-llvm-${{ env.LLVM_VER }} | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{version}}-llvm-${{ env.LLVM_VER }} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}}.{{minor}}-llvm-${{ env.LLVM_VER }} | |
| type=semver,pattern={{major}} | |
| type=semver,pattern={{major}}-llvm-${{ env.LLVM_VER }} | |
| type=sha | |
| type=schedule | |
| - | |
| name: Set up Docker Buildx | |
| id: setup-buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - | |
| name: Login to Docker Hub | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - | |
| name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - | |
| name: Restore ccache | |
| id: ccache | |
| uses: actions/cache@v4 | |
| with: | |
| path: /tmp/ccache-buildkit | |
| key: ccache-${{ hashFiles('Dockerfile') }}-${{ github.sha }} | |
| restore-keys: | | |
| ccache-${{ hashFiles('Dockerfile') }}- | |
| ccache- | |
| - | |
| name: Inject/extract ccache for BuildKit | |
| uses: reproducible-containers/buildkit-cache-dance@v3.3.2 | |
| with: | |
| builder: ${{ steps.setup-buildx.outputs.name }} | |
| cache-dir: /tmp/ccache-buildkit | |
| - | |
| name: Compute cache tag | |
| id: cache-tag | |
| run: | | |
| # Sanitize ref name for use as a Docker tag | |
| # (e.g., PR refs "1/merge" or branch "feature/foo" contain invalid "/" chars) | |
| echo "ref=${GITHUB_REF_NAME//\//-}" >> "$GITHUB_OUTPUT" | |
| - | |
| name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| pull: true | |
| build-args: | | |
| PHASED_BUILD=true | |
| AVAIL_MEM_KB=16567500 | |
| LLVM_VER=${{ env.LLVM_VER }} | |
| ${{ env.NINJA_MAX_JOBS && format('NINJA_MAX_JOBS={0}', env.NINJA_MAX_JOBS) || '' }} | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| cache-from: | | |
| type=registry,ref=ghcr.io/paratoolsinc/salt-dev:buildcache | |
| type=registry,ref=ghcr.io/paratoolsinc/salt-dev:buildcache-${{ steps.cache-tag.outputs.ref }} | |
| cache-to: type=registry,ref=ghcr.io/paratoolsinc/salt-dev:buildcache-${{ steps.cache-tag.outputs.ref }},mode=max | |
| - | |
| name: Update shared build cache | |
| if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| build-args: | | |
| PHASED_BUILD=true | |
| AVAIL_MEM_KB=16567500 | |
| LLVM_VER=${{ env.LLVM_VER }} | |
| ${{ env.NINJA_MAX_JOBS && format('NINJA_MAX_JOBS={0}', env.NINJA_MAX_JOBS) || '' }} | |
| push: false | |
| tags: salt-dev:cache-warmup | |
| cache-from: type=registry,ref=ghcr.io/paratoolsinc/salt-dev:buildcache-${{ steps.cache-tag.outputs.ref }} | |
| cache-to: type=registry,ref=ghcr.io/paratoolsinc/salt-dev:buildcache,mode=max | |
| - | |
| name: Update repo description | |
| if: github.event_name != 'pull_request' | |
| uses: peter-evans/dockerhub-description@v5 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| repository: paratools/salt-dev | |
| build-devtools: | |
| needs: [lint, build-base] | |
| if: github.event_name != 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - | |
| name: Checkout | |
| uses: actions/checkout@v6 | |
| - | |
| name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| paratools/salt-dev-tools | |
| ghcr.io/paratoolsinc/salt-dev-tools | |
| tags: | | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=raw,value=latest-llvm-${{ env.LLVM_VER }},enable={{is_default_branch}} | |
| type=ref,event=branch | |
| type=ref,event=branch,suffix=-llvm-${{ env.LLVM_VER }} | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{version}}-llvm-${{ env.LLVM_VER }} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}}.{{minor}}-llvm-${{ env.LLVM_VER }} | |
| type=semver,pattern={{major}} | |
| type=semver,pattern={{major}}-llvm-${{ env.LLVM_VER }} | |
| type=sha | |
| type=schedule | |
| - | |
| name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - | |
| name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - | |
| name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - | |
| name: Compute cache tag | |
| id: cache-tag | |
| run: | | |
| # Sanitize ref name for use as a Docker tag | |
| # (e.g., PR refs "1/merge" or branch "feature/foo" contain invalid "/" chars) | |
| echo "ref=${GITHUB_REF_NAME//\//-}" >> "$GITHUB_OUTPUT" | |
| - | |
| name: Determine base tag | |
| id: base-tag | |
| run: | | |
| # Use the branch/tag name that was just built as the base tag | |
| if [[ "$GITHUB_REF" == refs/tags/* ]]; then | |
| echo "tag=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "tag=${GITHUB_REF#refs/heads/}" >> "$GITHUB_OUTPUT" | |
| fi | |
| - | |
| name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile.devtools | |
| pull: true | |
| build-args: | | |
| BASE_TAG=${{ steps.base-tag.outputs.tag }} | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| cache-from: | | |
| type=registry,ref=ghcr.io/paratoolsinc/salt-dev-tools:buildcache | |
| type=registry,ref=ghcr.io/paratoolsinc/salt-dev-tools:buildcache-${{ steps.cache-tag.outputs.ref }} | |
| cache-to: type=registry,ref=ghcr.io/paratoolsinc/salt-dev-tools:buildcache-${{ steps.cache-tag.outputs.ref }},mode=max | |
| - | |
| name: Update shared build cache | |
| if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile.devtools | |
| build-args: | | |
| BASE_TAG=${{ steps.base-tag.outputs.tag }} | |
| push: false | |
| tags: salt-dev-tools:cache-warmup | |
| cache-from: type=registry,ref=ghcr.io/paratoolsinc/salt-dev-tools:buildcache-${{ steps.cache-tag.outputs.ref }} | |
| cache-to: type=registry,ref=ghcr.io/paratoolsinc/salt-dev-tools:buildcache,mode=max | |
| - | |
| name: Update repo description | |
| uses: peter-evans/dockerhub-description@v5 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| repository: paratools/salt-dev-tools |