-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
1,146 additions
and
918 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
Checklist: | ||
* [ ] The package builds locally with `./piston build-pkg [package] [version]` | ||
* [ ] The package installs with `./piston ppman install [package]=[version]` | ||
* [ ] The package runs the test code with `./piston run [package] -l [version] packages/[package]/[version]/test.*` | ||
* [ ] Package files are placed in the correct directory | ||
* [ ] No old package versions are removed | ||
* [ ] All source files are deleted in the `build.sh` script | ||
* [ ] `metadata.json`'s `language` and `version` fields match the directory path | ||
* [ ] Any extensions the language may use are set as aliases | ||
* [ ] Any alternative names the language is referred to are set as aliases. | ||
|
||
- [ ] The package builds locally with `./piston build-pkg [package] [version]` | ||
- [ ] The package installs with `./piston ppman install [package]=[version]` | ||
- [ ] The package runs the test code with `./piston run [package] -l [version] packages/[package]/[version]/test.*` | ||
- [ ] Package files are placed in the correct directory | ||
- [ ] No old package versions are removed | ||
- [ ] All source files are deleted in the `build.sh` script | ||
- [ ] `metadata.json`'s `language` and `version` fields match the directory path | ||
- [ ] Any extensions the language may use are set as aliases | ||
- [ ] Any alternative names the language is referred to are set as aliases. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,38 @@ | ||
name: Publish API image | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- v3 | ||
paths: | ||
- api/** | ||
push: | ||
branches: | ||
- master | ||
- v3 | ||
paths: | ||
- api/** | ||
|
||
|
||
jobs: | ||
push_to_registry: | ||
runs-on: ubuntu-latest | ||
name: Build and Push Docker image to Github Packages | ||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v2 | ||
- name: Login to GitHub registry | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: docker.pkg.github.com | ||
- name: Login to ghcr.io | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: ghcr.io | ||
push_to_registry: | ||
runs-on: ubuntu-latest | ||
name: Build and Push Docker image to Github Packages | ||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v2 | ||
- name: Login to GitHub registry | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: docker.pkg.github.com | ||
- name: Login to ghcr.io | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: ghcr.io | ||
|
||
- name: Build and push API | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: api | ||
push: true | ||
pull: true | ||
tags: | | ||
docker.pkg.github.com/engineer-man/piston/api | ||
ghcr.io/engineer-man/piston | ||
- name: Build and push API | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: api | ||
push: true | ||
pull: true | ||
tags: | | ||
docker.pkg.github.com/engineer-man/piston/api | ||
ghcr.io/engineer-man/piston |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,140 +1,140 @@ | ||
name: "Package Pull Requests" | ||
name: 'Package Pull Requests' | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- edited | ||
- reopened | ||
- synchronize | ||
paths: | ||
- "packages/**" | ||
pull_request: | ||
types: | ||
- opened | ||
- edited | ||
- reopened | ||
- synchronize | ||
paths: | ||
- 'packages/**' | ||
|
||
jobs: | ||
check-pkg: | ||
name: Validate README | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Get list of changed files | ||
uses: lots0logs/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Ensure README was updated | ||
run: | | ||
MISSING_LINES=$(comm -23 <(jq 'if .provides then .provides[].language else .language end' -r $(find packages -name "metadata.json" ) | sed -e 's/^/`/g' -e 's/$/`,/g' | sort -u) <(awk '/# Supported Languages/{flag=1; next} /<br>/{flag=0} flag' readme.md | sort -u)) | ||
[[ $(echo $MISSING_LINES | wc -c) = "1" ]] && exit 0 | ||
echo "README has supported languages missing: " | ||
comm -23 <(jq 'if .provides then .provides[].language else .language end' -r $(find packages -name "metadata.json" ) | sed -e 's/^/`/g' -e 's/$/`,/g' | sort -u) <(awk '/# Supported Languages/{flag=1; next} /<br>/{flag=0} flag' readme.md | sort -u) | ||
exit 1 | ||
build-pkg: | ||
name: Check that package builds | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Login to GitHub registry | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: docker.pkg.github.com | ||
|
||
- name: Get list of changed files | ||
uses: lots0logs/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build Packages | ||
run: | | ||
PACKAGES=$(jq '.[]' -r ${HOME}/files.json | awk -F/ '$2 && $3{ print $2 "-" $3 }' | sort -u) | ||
echo "Packages: $PACKAGES" | ||
docker pull docker.pkg.github.com/engineer-man/piston/repo-builder:latest | ||
docker build -t repo-builder repo | ||
docker run -v "${{ github.workspace }}:/piston" repo-builder --no-server $PACKAGES | ||
ls -la packages | ||
- name: Upload package as artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: packages | ||
path: packages/*.pkg.tar.gz | ||
|
||
test-pkg: | ||
name: Test package | ||
runs-on: ubuntu-latest | ||
needs: build-pkg | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: packages | ||
|
||
- name: Relocate downloaded packages | ||
run: mv *.pkg.tar.gz packages/ | ||
|
||
- name: Login to GitHub registry | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: docker.pkg.github.com | ||
|
||
- name: Run tests | ||
run: | | ||
ls -la | ||
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 | ||
docker pull docker.pkg.github.com/engineer-man/piston/api | ||
docker build -t piston-api api | ||
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 piston-api | ||
echo Waiting for API to start.. | ||
docker run --network container:api appropriate/curl -s --retry 10 --retry-connrefused http://localhost:2000/api/v2/runtimes | ||
echo Waiting for Index to start.. | ||
docker run --network container:repo appropriate/curl -s --retry 999 --retry-max-time 0 --retry-connrefused http://localhost:8000/index | ||
echo Adjusting index | ||
sed -i 's/repo/localhost/g' repo/index | ||
echo Listing Packages | ||
PACKAGES_JSON=$(docker run --network container:api appropriate/curl -s http://localhost:2000/api/v2/packages) | ||
echo $PACKAGES_JSON | ||
echo Getting CLI ready | ||
docker run -v "$PWD/cli:/app" --entrypoint /bin/bash node:15 -c 'cd /app; npm i' | ||
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..." | ||
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\"}" | ||
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 | ||
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 | ||
cat test_output | ||
grep "OK" test_output | ||
done | ||
done | ||
- name: Dump logs | ||
if: ${{ always() }} | ||
run: | | ||
docker logs api | ||
docker logs repo | ||
check-pkg: | ||
name: Validate README | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Get list of changed files | ||
uses: lots0logs/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Ensure README was updated | ||
run: | | ||
MISSING_LINES=$(comm -23 <(jq 'if .provides then .provides[].language else .language end' -r $(find packages -name "metadata.json" ) | sed -e 's/^/`/g' -e 's/$/`,/g' | sort -u) <(awk '/# Supported Languages/{flag=1; next} /<br>/{flag=0} flag' readme.md | sort -u)) | ||
[[ $(echo $MISSING_LINES | wc -c) = "1" ]] && exit 0 | ||
echo "README has supported languages missing: " | ||
comm -23 <(jq 'if .provides then .provides[].language else .language end' -r $(find packages -name "metadata.json" ) | sed -e 's/^/`/g' -e 's/$/`,/g' | sort -u) <(awk '/# Supported Languages/{flag=1; next} /<br>/{flag=0} flag' readme.md | sort -u) | ||
exit 1 | ||
build-pkg: | ||
name: Check that package builds | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Login to GitHub registry | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: docker.pkg.github.com | ||
|
||
- name: Get list of changed files | ||
uses: lots0logs/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build Packages | ||
run: | | ||
PACKAGES=$(jq '.[]' -r ${HOME}/files.json | awk -F/ '$2 && $3{ print $2 "-" $3 }' | sort -u) | ||
echo "Packages: $PACKAGES" | ||
docker pull docker.pkg.github.com/engineer-man/piston/repo-builder:latest | ||
docker build -t repo-builder repo | ||
docker run -v "${{ github.workspace }}:/piston" repo-builder --no-server $PACKAGES | ||
ls -la packages | ||
- name: Upload package as artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: packages | ||
path: packages/*.pkg.tar.gz | ||
|
||
test-pkg: | ||
name: Test package | ||
runs-on: ubuntu-latest | ||
needs: build-pkg | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: packages | ||
|
||
- name: Relocate downloaded packages | ||
run: mv *.pkg.tar.gz packages/ | ||
|
||
- name: Login to GitHub registry | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: docker.pkg.github.com | ||
|
||
- name: Run tests | ||
run: | | ||
ls -la | ||
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 | ||
docker pull docker.pkg.github.com/engineer-man/piston/api | ||
docker build -t piston-api api | ||
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 piston-api | ||
echo Waiting for API to start.. | ||
docker run --network container:api appropriate/curl -s --retry 10 --retry-connrefused http://localhost:2000/api/v2/runtimes | ||
echo Waiting for Index to start.. | ||
docker run --network container:repo appropriate/curl -s --retry 999 --retry-max-time 0 --retry-connrefused http://localhost:8000/index | ||
echo Adjusting index | ||
sed -i 's/repo/localhost/g' repo/index | ||
echo Listing Packages | ||
PACKAGES_JSON=$(docker run --network container:api appropriate/curl -s http://localhost:2000/api/v2/packages) | ||
echo $PACKAGES_JSON | ||
echo Getting CLI ready | ||
docker run -v "$PWD/cli:/app" --entrypoint /bin/bash node:15 -c 'cd /app; npm i' | ||
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..." | ||
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\"}" | ||
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 | ||
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 | ||
cat test_output | ||
grep "OK" test_output | ||
done | ||
done | ||
- name: Dump logs | ||
if: ${{ always() }} | ||
run: | | ||
docker logs api | ||
docker logs repo |
Oops, something went wrong.