Skip to content

Commit

Permalink
Add support for actions CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain Beauxis authored and toots committed Dec 24, 2021
1 parent 4197e15 commit b2a5783
Show file tree
Hide file tree
Showing 9 changed files with 439 additions and 2 deletions.
35 changes: 35 additions & 0 deletions .github/check-installable/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Check if package is installable
inputs:
opam:
required: true
package:
reauired: true
outputs:
installable:
description: "Is the package installable?"
value: ${{ steps.installable.outputs.installable }}
runs:
using: composite
steps:
- name: Get opam cli option
id: cli
shell: sh
run: |
if [ "${{ inputs.opam }}" = "opam-2.1" ]; then
echo '##[set-output name=cli]--cli=2.1'
fi
- name: Check if package is installable
id: installable
shell: sh
run: |
if opam ${{ steps.cli.outputs.cli }} list --readonly --external --resolve=${{ inputs.package }} >/dev/null 2>&1; then
echo '##[set-output name=installable]true';
else
echo "Package is not installable";
fi
- name: Annotate result
if: ${{ !steps.installable.outputs.installable }}
uses: actions/github-script@v5
with:
script: |
core.notice('${{ inputs.package }} is not installable');
14 changes: 14 additions & 0 deletions .github/install-ocaml/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Install OCaml
inputs:
compiler:
reauired: true
runs:
using: composite
steps:
- name: Setup OCaml
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ inputs.compiler }}
opam-disable-sandboxing: true
opam-repositories: |
default: file://.
30 changes: 30 additions & 0 deletions .github/install-package/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Install Package
inputs:
opam:
required: true
package:
reauired: true
env:
default: '{}'
runs:
using: composite
steps:
- name: Get opam cli option
id: cli
shell: sh
run: |
if [ "${{ inputs.opam }}" = "opam-2.1" ]; then
echo '##[set-output name=cli]--cli=2.1 --confirm-level=unsafe-yes'
fi
- name: Install ${{ inputs.package }} depopts
if: inputs.opam == 'opam-2.0'
shell: sh
run: |
opam depext ${{ inputs.package }}
- name: Install ${{ inputs.package }}
shell: sh
env: ${{ fromJson(inputs.env) }}
run: |
opam install --deps-only ${{ steps.cli.outputs.cli }} ${{ inputs.package }}
opam install ${{ steps.cli.outputs.cli }} ${{ inputs.package }}
opam remove ${{ steps.cli.outputs.cli }} ${{ inputs.package }}
35 changes: 35 additions & 0 deletions .github/install-system-packages/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Install System Packages
inputs:
distribution:
reauired: true
runs:
using: composite
steps:
- name: Install debian system packages
if: startsWith(inputs.distribution, 'debian') || startsWith(inputs.distribution, 'ubuntu')
shell: sh
env:
DEBIAN_FRONTEND: noninteractive
run: |
apt-get update
apt-get install -qq -yy curl darcs gcc git m4 make mercurial patch rsync sudo unzip bzip2
- name: Install alpine system packages
if: startsWith(inputs.distribution, 'alpine')
shell: sh
run: |
apk add build-base coreutils curl libgcc libstdc++ musl patch unzip bzip2 mercurial git rsync tar
- name: Install yum-based system packages
if: startsWith(inputs.distribution, 'centos') || startsWith(inputs.distribution, 'fedora') || startsWith(inputs.distribution, 'oraclelinux')
shell: sh
run: |
yum install -y curl diffutils gcc gcc-c++ tar git m4 make mercurial patch rsync sudo unzip gzip bzip2
- name: Install opensuse system packages
if: startsWith(inputs.distribution, 'opensuse')
shell: sh
run: |
zypper install -y curl diffutils gcc gcc-c++ tar git m4 make mercurial patch rsync sudo unzip gzip bzip2 which
- name: Install archlinux system packages
if: startsWith(inputs.distribution, 'archlinux')
shell: sh
run: |
pacman -Sy --noconfirm base-devel unzip git rsync
26 changes: 26 additions & 0 deletions .github/package-revdeps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Get package revdeps
inputs:
package:
reauired: true
cache_key:
required: true
runs:
using: composite
steps:
- name: Store package revdeps
uses: actions/cache@v2
id: cache_revdeps
with:
path: ${{ inputs.package }}.revdeps
key: ${{ inputs.cache_key }}-${{ inputs.package }}

- name: Get package revdeps
id: revdeps
shell: sh
if: ${{ !steps.cache_revdeps.outputs.cache-hit }}
env:
OCAMLCLI: ''
run: |
REVDEPS=`(opam list -s --color=never --depends-on ${{ inputs.package }} --coinstallable-with ${{ inputs.package }} --installable --all-versions --recursive --depopts && opam list -s --color=never --depends-on ${{ inputs.package }} --coinstallable-with ${{ inputs.package }} --installable --all-versions --with-test --depopts) | sort -u | grep -v ${{ inputs.package }} | while read i; do echo "\"$i\""; done | paste -sd ',' -`
echo "${{ inputs.package }} revdeps: [$REVDEPS]"
echo "[$REVDEPS]" > ${{ inputs.package }}.revdeps
38 changes: 38 additions & 0 deletions .github/revdeps-config/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Get revdeps configl
inputs:
packages:
reauired: true
cache_key:
required: true
outputs:
revdeps_config:
description: "Revdeps config"
value: ${{ steps.revdeps_config.outputs.result }}
runs:
using: composite
steps:
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install @action/cache
shell: sh
run: npm install @actions/cache
- name: Collect revdeps
id: revdeps_config
uses: actions/github-script@v5
with:
script: |
const cache = require('@actions/cache');
const fs = require('fs');
let config = [];
const packages = JSON.parse('${{ inputs.packages }}');
await Promise.all(packages.map(async (package) => {
await cache.restoreCache([`${package}.revdeps`], `${{ inputs.cache_key }}-${package}`);
const revdeps = JSON.parse(fs.readFileSync(`${package}.revdeps`));
revdeps.forEach((revdep) => config.push({package, revdep}));
}));
console.log(`Revdeps config: ${JSON.stringify(config, null, 2)}`);
return config;
9 changes: 9 additions & 0 deletions .github/scripts/packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

set -e

PACKAGES=`git diff --name-only origin/master..HEAD | grep '^packages' | cut -d'/' -f 3 | while read i; do echo "\"$i\""; done`
echo "Packages to test: [$PACKAGES]"
echo "##[set-output name=packages][${PACKAGES}]"
Loading

0 comments on commit b2a5783

Please sign in to comment.