add packages to OCaml 5.1 image #93
Workflow file for this run
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: OCaml-General | |
on: | |
push: | |
paths: | |
- 'ocaml-general/**' | |
- '!ocaml-general/README.md' | |
- '.github/workflows/ocaml-general.yml' | |
branches: [main] | |
workflow_dispatch: | |
inputs: | |
ref: | |
description: branch|tag|SHA to checkout | |
default: 'main' | |
required: true | |
schedule: | |
# 日本時間の月曜日午前2時に毎週実行される | |
- cron: '0 17 * * 0' | |
pull_request: | |
types: [opened, synchronize, reopened, ready_for_review] | |
paths: | |
- 'ocaml-general/**' | |
- '!ocaml-general/README.md' | |
- '.github/workflows/ocaml-general.yml' | |
merge_group: | |
jobs: | |
validate-ocaml-general: | |
strategy: | |
matrix: | |
ocaml-version: | |
- 4.13.1 | |
- 5.0.0 | |
- 5.1.0 | |
arch: | |
- amd64 | |
# - arm64 # it's taking too long for the purpose of validation | |
node-version: | |
- iron # v18 Active LTS | |
os: | |
- ubuntu.22.04 | |
env: | |
DOCKER_TAG: ${{ matrix.os }}-ocaml.${{ matrix.ocaml-version }}-node.${{ matrix.node-version }}-${{ matrix.arch }} | |
CACHE_DIR: /tmp/docker-cache | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up env var | |
run: echo "PACKAGE_INSTALL_SCRIPT_FILENAME=install_ocaml_$(eval cut -d'.' -f1-2 <<< ${{ matrix.ocaml-version }})_packages.sh" | tee -a $GITHUB_ENV | |
- name: Set up QEMU for arm64 | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: arm64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- run: mkdir -p ${{ env.CACHE_DIR }} | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.CACHE_DIR }} | |
key: ${{ runner.os }}-buildx-${{ matrix.arch }}-${{ env.DOCKER_TAG }}-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx-${{ matrix.arch }}-${{ env.DOCKER_TAG }} | |
${{ runner.os }}-buildx-${{ matrix.arch }}- | |
- name: Validation Docker Build (${{ env.DOCKER_TAG }}) | |
uses: docker/build-push-action@v4 | |
with: | |
context: ocaml-general | |
push: false | |
platforms: linux/${{ matrix.arch }} | |
build-args: | | |
NODE_VERSION=${{ matrix.node-version }} | |
OCAML_VERSION=${{ matrix.ocaml-version }} | |
PACKAGE_INSTALL_SCRIPT_FILENAME=${{ env.PACKAGE_INSTALL_SCRIPT_FILENAME }} | |
cache-from: type=local,src=${{ env.CACHE_DIR }}/.buildx-cache | |
cache-to: type=local,dest=${{ env.CACHE_DIR }}/.buildx-cache-new,mode=max | |
- name: Move cache | |
run: | | |
cd ${{ env.CACHE_DIR }} | |
rm -rf .buildx-cache | |
mv .buildx-cache-new .buildx-cache | |
ocaml-general-validated: | |
needs: validate-ocaml-general | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo "all clear" | |
build-deploy-ocaml-general: | |
needs: validate-ocaml-general | |
strategy: | |
matrix: | |
ocaml-version: | |
- 4.13.1 | |
- 4.14.1 | |
- 5.0.0 | |
- 5.1.0 | |
arch: | |
- amd64 | |
- arm64 | |
node-version: | |
- hydrogen # v18 Active LTS | |
- iron # v20 Active LTS | |
- latest | |
os: | |
- ubuntu.22.04 | |
env: | |
DOCKER_TAG: ${{ matrix.os }}-ocaml.${{ matrix.ocaml-version }}-node.${{ matrix.node-version }}-${{ matrix.arch }} | |
CACHE_DIR: /tmp/docker-cache | |
PACKAGE_NAME: ghcr.io/kxcinc/ocaml-general | |
if: github.event.pull_request.draft == false | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up env var | |
run: | | |
echo "PACKAGE_INSTALL_SCRIPT_FILENAME=install_ocaml_$(eval cut -d'.' -f1-2 <<< ${{ matrix.ocaml-version }})_packages.sh" | tee -a $GITHUB_ENV | |
echo "DOCKER_TAG_LIST=${{ env.PACKAGE_NAME }}:${{ env.DOCKER_TAG }},${{ env.PACKAGE_NAME }}:${{ env.DOCKER_TAG }}-${{ github.sha }}" | tee -a $GITHUB_ENV | tr '=,' '\n' | sort | |
- name: Set up env var for alias (node iron && arch amd64) | |
if: ${{ matrix.node-version == 'iron' && matrix.arch == 'amd64' }} | |
run: echo "DOCKER_TAG_LIST=${{ env.DOCKER_TAG_LIST }},${{ env.PACKAGE_NAME }}:${{ matrix.ocaml-version }},${{ env.PACKAGE_NAME }}:${{ matrix.ocaml-version }}-${{ github.sha }}" | tee -a $GITHUB_ENV | tr '=,' '\n' | sort | |
- name: Set up QEMU for arm64 | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: arm64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# https://github.com/docker/build-push-action/issues/761#issuecomment-1575006515 | |
# https://github.com/kxcinc/pubinfra.dockerfiles/issues/37 | |
with: | |
driver-opts: | | |
image=moby/buildkit:v0.10.6 | |
- run: mkdir -p ${{ env.CACHE_DIR }} | |
- name: Restore Docker Layers Cache | |
if: github.event.schedule == null | |
uses: actions/cache/restore@v3 | |
with: | |
path: ${{ env.CACHE_DIR }} | |
key: ${{ runner.os }}-buildx-${{ matrix.arch }}-${{ env.DOCKER_TAG }}-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx-${{ matrix.arch }}-${{ env.DOCKER_TAG }} | |
${{ runner.os }}-buildx-${{ matrix.arch }}- | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push image (${{ env.DOCKER_TAG }}) | |
uses: docker/build-push-action@v4 | |
with: | |
context: ocaml-general | |
push: ${{ github.ref == 'refs/heads/main' }} | |
platforms: linux/${{ matrix.arch }} | |
build-args: | | |
NODE_VERSION=${{ matrix.node-version }} | |
OCAML_VERSION=${{ matrix.ocaml-version }} | |
PACKAGE_INSTALL_SCRIPT_FILENAME=${{ env.PACKAGE_INSTALL_SCRIPT_FILENAME }} | |
tags: ${{ env.DOCKER_TAG_LIST }} | |
cache-from: type=local,src=${{ env.CACHE_DIR }}/.buildx-cache | |
cache-to: type=local,dest=${{ env.CACHE_DIR }}/.buildx-cache-new,mode=max | |
- name: Move cache | |
run: | | |
cd ${{ env.CACHE_DIR }} | |
rm -rf .buildx-cache | |
mv .buildx-cache-new .buildx-cache | |
- name: Store Docker Layers Cache | |
if: ${{ matrix.ocaml-version == '5.1.0' && matrix.node-version == 'iron' }} | |
uses: actions/cache/save@v3 | |
with: | |
path: ${{ env.CACHE_DIR }} | |
key: ${{ runner.os }}-buildx-${{ matrix.arch }}-${{ env.DOCKER_TAG }}-${{ github.sha }} | |
ocaml-general-matrix-checked: | |
needs: build-deploy-ocaml-general | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo "all clear" |