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 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-04-25 06:41:02 +02:00
|
|
|
docker run -v $(pwd)'/repo:/piston/repo' -v $(pwd)'/packages:/piston/packages' -d --name repo docker.pkg.github.com/engineer-man/piston/repo-builder --no-build
|
2021-05-07 11:11:36 +02:00
|
|
|
docker run --network container:repo -v $(pwd)'/data:/piston' -e PISTON_LOG_LEVEL=DEBUG -e 'PISTON_REPO_URL=http://localhost:8000/index' -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-05-07 21:22:25 +02:00
|
|
|
docker run --network container:api appropriate/curl -s --retry 10 --retry-connrefused http://localhost:2000/api/v2/runtimes
|
2021-03-14 00:34:54 +01:00
|
|
|
|
2021-03-14 06:05:20 +01:00
|
|
|
echo Waiting for Index to start..
|
2021-04-25 06:43:57 +02:00
|
|
|
docker run --network container:repo appropriate/curl -s --retry 999 --retry-max-time 0 --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
|
2021-04-25 06:43:57 +02:00
|
|
|
sed -i 's/repo/localhost/g' repo/index
|
2021-03-14 07:21:41 +01:00
|
|
|
|
2021-03-14 05:57:11 +01:00
|
|
|
echo Listing Packages
|
2021-05-07 21:22:25 +02:00
|
|
|
PACKAGES_JSON=$(docker run --network container:api appropriate/curl -s http://localhost:2000/api/v2/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-29 10:33:49 +02:00
|
|
|
docker run -v "$PWD/cli:/app" --entrypoint /bin/bash node:15 -c 'cd /app; npm i'
|
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-05-09 03:40:41 +02:00
|
|
|
docker run --network container:api appropriate/curl -sXPOST http://localhost:2000/api/v2/packages -H "Content-Type: application/json" -d "{\"language\":\"$PKG_NAME\",\"version\":\"$PKG_VERSION\"}"
|
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-04-27 02:15:33 +02:00
|
|
|
docker run --network container:api -v "$PWD/cli:/app" -v "$PWD/$(dirname $tscript):/pkg" node:15 /app/index.js run $TEST_RUNTIME -l $PKG_VERSION /pkg/$(basename $tscript) > test_output
|
2021-03-15 20:24:43 +01:00
|
|
|
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
|
2021-04-27 02:10:12 +02:00
|
|
|
docker logs repo
|
2021-03-14 06:15:05 +01:00
|
|
|
|
2021-02-28 07:30:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-03-14 07:31:41 +01:00
|
|
|
|
|
|
|
|