2021-02-28 03:58:02 +01:00
|
|
|
name: 'Package Pull Requests'
|
|
|
|
|
|
|
|
on:
|
2021-02-28 04:07:16 +01:00
|
|
|
pull_request:
|
2021-02-28 03:58:02 +01:00
|
|
|
types:
|
|
|
|
- opened
|
|
|
|
- edited
|
|
|
|
- reopened
|
|
|
|
- synchronize
|
|
|
|
paths:
|
|
|
|
- 'packages/**'
|
|
|
|
|
|
|
|
jobs:
|
2021-03-14 01:49:30 +01:00
|
|
|
build-pkg:
|
2021-02-28 07:30:35 +01:00
|
|
|
name: Check that package builds
|
2021-02-28 03:58:02 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2021-02-28 07:30:35 +01:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
2021-03-14 01:02:54 +01:00
|
|
|
|
|
|
|
- name: Login to GitHub registry
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
registry: docker.pkg.github.com
|
2021-03-14 04:41:52 +01:00
|
|
|
|
|
|
|
- name: Get list of changed files
|
|
|
|
uses: lots0logs/gh-action-get-changed-files@2.1.4
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2021-02-28 07:30:35 +01:00
|
|
|
- name: Build Packages
|
|
|
|
run: |
|
2021-03-14 04:43:50 +01:00
|
|
|
PACKAGES=$(jq '.[]' -r ${HOME}/files.json | awk -F/ '{ print $2 "-" $3 }' | sort -u)
|
|
|
|
echo "Packages: $PACKAGES"
|
|
|
|
docker run -v "${{ github.workspace }}:/piston" docker.pkg.github.com/engineer-man/piston/repo-builder:latest --no-server $PACKAGES
|
2021-03-14 04:38:48 +01:00
|
|
|
ls -la packages
|
2021-03-14 00:34:54 +01:00
|
|
|
|
2021-03-14 01:49:30 +01:00
|
|
|
- name: Upload package as artifact
|
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: packages
|
|
|
|
path: packages/*.pkg.tar.gz
|
|
|
|
|
|
|
|
|
2021-03-14 01:50:44 +01:00
|
|
|
test-pkg:
|
|
|
|
name: Test package
|
|
|
|
runs-on: ubuntu-latest
|
2021-03-14 01:52:20 +01:00
|
|
|
needs: build-pkg
|
2021-03-14 01:50:44 +01:00
|
|
|
steps:
|
2021-03-14 01:49:30 +01:00
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- uses: actions/download-artifact@v2
|
|
|
|
with:
|
|
|
|
name: packages
|
2021-03-14 06:37:11 +01:00
|
|
|
|
|
|
|
- name: Relocate downloaded packages
|
|
|
|
run: mv *.pkg.tar.gz packages/
|
2021-03-14 01:49:30 +01:00
|
|
|
|
2021-03-14 00:34:54 +01:00
|
|
|
- name: Write test config file
|
2021-03-14 00:39:26 +01:00
|
|
|
uses: DamianReeves/write-file-action@v1.0
|
2021-03-14 00:34:54 +01:00
|
|
|
with:
|
|
|
|
path: data/config.yaml
|
|
|
|
contents: |
|
|
|
|
log_level: DEBUG
|
2021-03-28 21:01:46 +02:00
|
|
|
bind_address: 0.0.0.0:2000
|
2021-03-14 00:34:54 +01:00
|
|
|
data_directory: /piston
|
|
|
|
runner_uid_min: 1100
|
|
|
|
runner_uid_max: 1500
|
|
|
|
runner_gid_min: 1100
|
|
|
|
runner_gid_max: 1500
|
|
|
|
enable_unshare: false
|
|
|
|
output_max_size: 1024
|
|
|
|
max_process_count: 64
|
|
|
|
max_open_files: 2048
|
2021-03-14 06:11:39 +01:00
|
|
|
repo_url: http://localhost:8000/index
|
2021-03-14 00:34:54 +01:00
|
|
|
|
|
|
|
write-mode: overwrite
|
2021-02-28 07:30:35 +01:00
|
|
|
|
2021-03-14 05:59:21 +01:00
|
|
|
- name: Login to GitHub registry
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
registry: docker.pkg.github.com
|
2021-03-14 06:01:45 +01:00
|
|
|
|
2021-02-28 07:30:35 +01:00
|
|
|
- name: Run tests
|
|
|
|
run: |
|
2021-03-14 06:37:11 +01:00
|
|
|
ls -la
|
2021-03-14 05:57:11 +01:00
|
|
|
docker run -v $(pwd)'/repo:/piston/repo' -v $(pwd)'/packages:/piston/packages' -d --name piston_fs_repo docker.pkg.github.com/engineer-man/piston/repo-builder --no-build
|
2021-03-14 06:11:39 +01:00
|
|
|
docker run --network container:piston_fs_repo -v $(pwd)'/data:/piston' -d --name api docker.pkg.github.com/engineer-man/piston/api
|
2021-02-28 07:30:35 +01:00
|
|
|
echo Waiting for API to start..
|
2021-03-28 21:01:46 +02:00
|
|
|
docker run --network container:api appropriate/curl -s --retry 10 --retry-connrefused http://localhost:2000/runtimes
|
2021-03-14 00:34:54 +01:00
|
|
|
|
2021-03-14 06:05:20 +01:00
|
|
|
echo Waiting for Index to start..
|
2021-03-14 07:07:54 +01:00
|
|
|
docker run --network container:piston_fs_repo appropriate/curl -s --retry 10 --retry-connrefused http://localhost:8000/index
|
2021-03-14 06:05:20 +01:00
|
|
|
|
2021-03-14 07:21:41 +01:00
|
|
|
echo Adjusting index
|
|
|
|
sed -i 's/piston_fs_repo/localhost/g' repo/index
|
|
|
|
|
2021-03-14 05:57:11 +01:00
|
|
|
echo Listing Packages
|
2021-03-28 21:01:46 +02:00
|
|
|
PACKAGES_JSON=$(docker run --network container:api appropriate/curl -s http://localhost:2000/packages)
|
2021-03-14 07:07:54 +01:00
|
|
|
echo $PACKAGES_JSON
|
|
|
|
|
2021-03-14 07:14:30 +01:00
|
|
|
echo Getting CLI ready
|
2021-03-14 07:21:41 +01:00
|
|
|
docker run -v "$PWD/cli:/app" --entrypoint /bin/bash node:15 -c 'cd /app; yarn'
|
2021-03-14 07:14:30 +01:00
|
|
|
|
2021-03-14 07:07:54 +01:00
|
|
|
for package in $(jq -r '.[] | "\(.language)-\(.language_version)"' <<< "$PACKAGES_JSON")
|
|
|
|
do
|
|
|
|
echo "Testing $package"
|
|
|
|
PKG_PATH=$(sed 's|-|/|' <<< $package)
|
|
|
|
PKG_NAME=$(awk -F- '{ print $1 }' <<< $package)
|
|
|
|
PKG_VERSION=$(awk -F- '{ print $2 }' <<< $package)
|
|
|
|
|
|
|
|
echo "Installing..."
|
2021-03-28 21:01:46 +02:00
|
|
|
docker run --network container:api appropriate/curl -sXPOST http://localhost:2000/packages/$PKG_PATH
|
2021-03-14 07:07:54 +01:00
|
|
|
|
|
|
|
TEST_SCRIPTS=packages/$PKG_PATH/test.*
|
|
|
|
echo "Tests: $TEST_SCRIPTS"
|
|
|
|
|
|
|
|
for tscript in $TEST_SCRIPTS
|
|
|
|
do
|
|
|
|
TEST_RUNTIME=$(awk -F. '{print $2}' <<< $(basename $tscript))
|
|
|
|
echo Running $tscript with runtime=$TEST_RUNTIME
|
2021-03-15 20:24:43 +01:00
|
|
|
docker run --network container:api -v "$PWD/cli:/app" -v "$PWD/$(dirname $tscript):/pkg" node:15 /app/index.js run $TEST_RUNTIME $PKG_VERSION /pkg/$(basename $tscript) > test_output
|
|
|
|
cat test_output
|
|
|
|
grep "OK" test_output
|
2021-03-14 07:07:54 +01:00
|
|
|
done
|
|
|
|
done
|
2021-02-28 07:30:35 +01:00
|
|
|
|
2021-03-14 07:31:41 +01:00
|
|
|
|
|
|
|
- name: Dump logs
|
|
|
|
if: ${{ always() }}
|
|
|
|
run: |
|
2021-03-14 06:15:05 +01:00
|
|
|
docker logs api
|
|
|
|
docker logs piston_fs_repo
|
|
|
|
|
2021-02-28 07:30:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-03-14 07:31:41 +01:00
|
|
|
|
|
|
|
|