From b1f13d2b871465b1d4c768d91f2407ede06f4da9 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 15:44:43 +1300 Subject: [PATCH 01/17] api,repo: Add libxml2 to container --- api/Dockerfile | 2 +- repo/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index 8e2b7eb..b3eb8a8 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,6 +1,6 @@ FROM node:15.8.0-buster-slim RUN dpkg-reconfigure -p critical dash -RUN apt-get update && apt-get install -y gnupg tar coreutils util-linux \ +RUN apt-get update && apt-get install -y libxml2 gnupg tar coreutils util-linux \ && rm -rf /var/lib/apt/lists/* RUN for i in $(seq 1001 1500); do \ diff --git a/repo/Dockerfile b/repo/Dockerfile index 730b8f1..8980d53 100644 --- a/repo/Dockerfile +++ b/repo/Dockerfile @@ -1,6 +1,6 @@ FROM debian:buster-slim -RUN apt-get update && apt-get install -y bc curl git linux-headers-amd64 perl xz-utils python3 python3-pip gnupg jq zlib1g-dev cmake cmake-doc extra-cmake-modules build-essential gcc binutils bash coreutils util-linux pciutils usbutils coreutils binutils findutils grep && \ +RUN apt-get update && apt-get install -y autoconf build-essential libssl-dev pkg-config zlib1g-dev libargon2-dev libsodium-dev libcurl4-openssl-dev sqlite3 libsqlite3-dev libonig-dev libxml2 libxml2-dev bc curl git linux-headers-amd64 perl xz-utils python3 python3-pip gnupg jq zlib1g-dev cmake cmake-doc extra-cmake-modules build-essential gcc binutils bash coreutils util-linux pciutils usbutils coreutils binutils findutils grep && \ ln -sf /bin/bash /bin/sh && \ pip3 install 'yq==2.12.0' && \ rm -rf /var/lib/apt/lists/* From ba539b89657fea85b3178f4fa6c9ebbbeeb46a23 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 15:58:02 +1300 Subject: [PATCH 02/17] ci: comment affected packages on prs --- .github/workflows/package-pr.yaml | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/package-pr.yaml diff --git a/.github/workflows/package-pr.yaml b/.github/workflows/package-pr.yaml new file mode 100644 index 0000000..a2697a3 --- /dev/null +++ b/.github/workflows/package-pr.yaml @@ -0,0 +1,49 @@ +name: 'Package Pull Requests' + +on: + pull_requests: + types: + - opened + - edited + - reopened + - synchronize + paths: + - 'packages/**' + +jobs: + packages-affected: + name: List affected packages + runs-on: ubuntu-latest + steps: + - name: Get PR Commits + id: 'get-pr-commits' + uses: tim-actions/get-pr-commits@master + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Check subsystem + if: ${{ success() || failure() }} + uses: tim-actions/commit-message-checker-with-regex@v0.3.1 + with: + commits: ${{ steps.get-pr-commits.outputs.commits }} + pattern: '^[\h]*(pkg\([^:\h\n]+\))[\h]*:' + error: 'Your commit message must start with pkg([package])' + + - name: Get packages + id: 'get-packages' + shell: bash + run: | + PACKAGES=$(echo '${{ steps.get-pr-commits.outputs.commits }}' | jq .[].commit.message -r | grep -oP '^pkg\(\K[^:\h\n]+(?=\))'' | sort -u | sed 's/^/* /') + PACKAGES=${PACKAGES//$'%'/'%25'} + PACKAGES=${PACKAGES//$'\n'/'%0A'} + PACKAGES=${PACKAGES//$'\r'/'%0D'} + echo "::set-output name=packages::$PACKAGES" + + + - name: Comment on PR + uses: unsplash/comment-on-pr@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + msg: "Affected packages:\n${{ steps.get-packages.outputs.packages }}" + check_for_duplicate_msg: true + \ No newline at end of file From 88faac0335fb4985ea83362e048e608153bb9640 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 16:07:16 +1300 Subject: [PATCH 03/17] ci: fix regex --- .github/workflows/package-pr.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package-pr.yaml b/.github/workflows/package-pr.yaml index a2697a3..6c3bce4 100644 --- a/.github/workflows/package-pr.yaml +++ b/.github/workflows/package-pr.yaml @@ -1,7 +1,7 @@ name: 'Package Pull Requests' on: - pull_requests: + pull_request: types: - opened - edited @@ -25,7 +25,7 @@ jobs: uses: tim-actions/commit-message-checker-with-regex@v0.3.1 with: commits: ${{ steps.get-pr-commits.outputs.commits }} - pattern: '^[\h]*(pkg\([^:\h\n]+\))[\h]*:' + pattern: '^[\s]*(pkg\([^:\s\n]+\))[\s]*:' error: 'Your commit message must start with pkg([package])' - name: Get packages From 792c7c69eb52354b0d67c948ec44c7be49cc302b Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 16:13:28 +1300 Subject: [PATCH 04/17] ci(package-pr): move into different var --- .github/workflows/package-pr.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/package-pr.yaml b/.github/workflows/package-pr.yaml index 6c3bce4..37ee491 100644 --- a/.github/workflows/package-pr.yaml +++ b/.github/workflows/package-pr.yaml @@ -32,7 +32,8 @@ jobs: id: 'get-packages' shell: bash run: | - PACKAGES=$(echo '${{ steps.get-pr-commits.outputs.commits }}' | jq .[].commit.message -r | grep -oP '^pkg\(\K[^:\h\n]+(?=\))'' | sort -u | sed 's/^/* /') + COMMITS='${{ steps.get-pr-commits.outputs.commits }}' + PACKAGES=$(echo $COMMITS | jq .[].commit.message -r | grep -oP '^pkg\(\K[^:\h\n]+(?=\))'' | sort -u | sed 's/^/* /') PACKAGES=${PACKAGES//$'%'/'%25'} PACKAGES=${PACKAGES//$'\n'/'%0A'} PACKAGES=${PACKAGES//$'\r'/'%0D'} From f0f5991bf3bef3d75968de19819b237ca45c044d Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 16:15:41 +1300 Subject: [PATCH 05/17] ci(package-pr): remove extra ' --- .github/workflows/package-pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package-pr.yaml b/.github/workflows/package-pr.yaml index 37ee491..31a571f 100644 --- a/.github/workflows/package-pr.yaml +++ b/.github/workflows/package-pr.yaml @@ -33,7 +33,7 @@ jobs: shell: bash run: | COMMITS='${{ steps.get-pr-commits.outputs.commits }}' - PACKAGES=$(echo $COMMITS | jq .[].commit.message -r | grep -oP '^pkg\(\K[^:\h\n]+(?=\))'' | sort -u | sed 's/^/* /') + PACKAGES=$(echo $COMMITS | jq .[].commit.message -r | grep -oP '^pkg\(\K[^:\h\n]+(?=\))' | sort -u | sed 's/^/* /') PACKAGES=${PACKAGES//$'%'/'%25'} PACKAGES=${PACKAGES//$'\n'/'%0A'} PACKAGES=${PACKAGES//$'\r'/'%0D'} From ab14de9ae84adb597f62700e939886ee2d9a3d54 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 16:21:38 +1300 Subject: [PATCH 06/17] ci(package-pr): use github scripts --- .github/workflows/package-pr.yaml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/package-pr.yaml b/.github/workflows/package-pr.yaml index 31a571f..de2f025 100644 --- a/.github/workflows/package-pr.yaml +++ b/.github/workflows/package-pr.yaml @@ -39,12 +39,11 @@ jobs: PACKAGES=${PACKAGES//$'\r'/'%0D'} echo "::set-output name=packages::$PACKAGES" - - - name: Comment on PR - uses: unsplash/comment-on-pr@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: 'Comment PR' + uses: actions/github-script@0.3.0 + if: github.event_name == 'pull_request' with: - msg: "Affected packages:\n${{ steps.get-packages.outputs.packages }}" - check_for_duplicate_msg: true - \ No newline at end of file + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { issue: { number: issue_number }, repo: { owner, repo } } = context; + github.issues.createComment({ issue_number, owner, repo, body: "Affected packages:\n${{ steps.get-packages.outputs.packages }}" }); \ No newline at end of file From 09802f9f2720a9ba5e2eeb07d68ac0ad4983a787 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 16:51:45 +1300 Subject: [PATCH 07/17] pkg(contributing): required test script --- packages/CONTRIBUTING.MD | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/CONTRIBUTING.MD b/packages/CONTRIBUTING.MD index d1b37d0..d0390a0 100644 --- a/packages/CONTRIBUTING.MD +++ b/packages/CONTRIBUTING.MD @@ -59,7 +59,21 @@ You should add in the path to any binaries. The current working directory for th If everything went well, you should now have a `[language]-[version].pkg.tar.gz` file sitting in the root. If not, read through your error logs, and if in doubt ask for help in #emkc-felix-piston in Discord. -14. Commit your changes, using message format of `pkg([language]): Added [language] [version]` +14. Create a source file for the app, which outputs `OK`, naming the file `[language-name].test` +For example, `mono` would have a file named `csharp-mono.test` containing: +```cs +using System; + +public class Test +{ + public static void Main(string[] args) + { + Console.WriteLine("OK"); + } +} +``` + +15. Commit your changes, using message format of `pkg([language]): Added [language] [version]` Any additional commits regarding this package should start with `pkg([language]): ` -15. Create a pull request (currently to v3), referencing an Issue number (if there is one associated). +16. Create a pull request (currently to v3), referencing an Issue number (if there is one associated). From a1a6702e75072f06a5f007a3b233bd0a7f0d620c Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 16:53:00 +1300 Subject: [PATCH 08/17] pkg(csharp-mono): add test --- packages/csharp-mono.test | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 packages/csharp-mono.test diff --git a/packages/csharp-mono.test b/packages/csharp-mono.test new file mode 100644 index 0000000..e91a2a2 --- /dev/null +++ b/packages/csharp-mono.test @@ -0,0 +1,9 @@ +using System; + +public class Test +{ + public static void Main(string[] args) + { + Console.WriteLine("OK"); + } +} \ No newline at end of file From b6f8ee88d8f95403ba4e5b826cc6337e5a830245 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 16:53:13 +1300 Subject: [PATCH 09/17] pkg(deno): add test --- packages/deno.test | 1 + 1 file changed, 1 insertion(+) create mode 100644 packages/deno.test diff --git a/packages/deno.test b/packages/deno.test new file mode 100644 index 0000000..56ed4a0 --- /dev/null +++ b/packages/deno.test @@ -0,0 +1 @@ +console.log("OK") \ No newline at end of file From d7687096ffae9a0210bbabb92a2302ed12720541 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 16:53:20 +1300 Subject: [PATCH 10/17] pkg(python): add test --- packages/python.test | 1 + 1 file changed, 1 insertion(+) create mode 100644 packages/python.test diff --git a/packages/python.test b/packages/python.test new file mode 100644 index 0000000..3f2688f --- /dev/null +++ b/packages/python.test @@ -0,0 +1 @@ +print("OK") \ No newline at end of file From d7a4292382f6d5585a7a9acdc1b5cc5fd3e588d3 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 18:20:10 +1300 Subject: [PATCH 11/17] pkg(python): 2.7.1 doesn't build properly --- packages/python.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/python.mk b/packages/python.mk index 02fe442..d0aa0ab 100644 --- a/packages/python.mk +++ b/packages/python.mk @@ -2,7 +2,7 @@ NAME=python AUTHOR=Thomas Hobson DEPENDENCIES= COMPILED=false -VERSIONS=2.7.1 3.5.1 3.9.1 +VERSIONS=3.5.1 3.9.1 include common.mk @@ -15,6 +15,7 @@ ${ENV_FILE}: ${BIN_DIR}: ${BUILD_DIR}Python-${VERSION}/ $(eval TMP_DIR=${PWD}/${BUILD_DIR}tmpout/) + cd $< && ./configure --prefix ${PREFIX} $(MAKE) -C $< DESTDIR=${TMP_DIR} $(MAKE) -C $< altinstall From 1ab3f463d0156cac4d31efb874fa5165e1e56f79 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 18:20:41 +1300 Subject: [PATCH 12/17] pkg(Makefile): add language specific build rules --- packages/Makefile | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/Makefile b/packages/Makefile index 91124e2..44fe47c 100644 --- a/packages/Makefile +++ b/packages/Makefile @@ -5,6 +5,8 @@ PKG_FILES=$(filter-out common.mk,$(wildcard *.mk)) PKG_SLUGS=$(foreach pkg, ${PKG_FILES}, $(addprefix $(shell make -f ${pkg} name VERSION=UNKNOWN)-, $(shell make -f ${pkg} versions VERSION=UNKNOWN))) # Functions +CALL_MAKE=$(shell make -f $1 $2 VERSION=UNKNOWN) + define pkg_info $(eval PKG_SLUG=$(patsubst $1-%,%,$2)) $(eval PKG_VERSION=$(lastword $(subst -, ,${PKG_SLUG}))) @@ -12,18 +14,27 @@ define pkg_info $(eval PKG_FILE=$(shell grep '^VERSIONS\s*=.*${PKG_VERSION}' $(shell grep "NAME\s*=\s*${PKG_NAME}" ${PKG_FILES} -l) -l)) endef +define per-lang +build-$(call CALL_MAKE, $1, name):: $$(addprefix build-$(call CALL_MAKE, $1, name)-, $$(call CALL_MAKE, $1, versions)) +clean-$(call CALL_MAKE, $1, name):: $$(addprefix clean-$(call CALL_MAKE, $1, name)-, $$(call CALL_MAKE, $1, versions)) +endef + + # Targets -build: $(foreach pkg, ${PKG_FILES}, $(addprefix build-$(shell make -f ${pkg} name VERSION=UNKNOWN)-, $(lastword $(shell make -f ${pkg} versions VERSION=UNKNOWN)))) +$(foreach e,${PKG_FILES}, $(eval $(call per-lang,${e}))) + +build build-all: $(foreach pkg, ${PKG_FILES}, build-$(call CALL_MAKE, ${pkg}, name)) $(addprefix build-, ${PKG_SLUGS}): $(call pkg_info,build,$@) $(MAKE) -f ${PKG_FILE} VERSION=${PKG_VERSION} build - - -clean: $(foreach pkg, ${PKG_FILES}, $(addprefix clean-$(shell make -f ${pkg} name VERSION=UNKNOWN)-, $(shell make -f ${pkg} versions VERSION=UNKNOWN))) +clean clean-all: $(foreach pkg, ${PKG_FILES}, clean-$(call CALL_MAKE, ${pkg}, name)) rm -rf build/ + $(addprefix clean-, ${PKG_SLUGS}): $(call pkg_info,clean,$@) $(MAKE) -f ${PKG_FILE} VERSION=${PKG_VERSION} clean + + From 1dd9e1a738844ca122419da8e96c8fc68ce872a0 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 18:23:28 +1300 Subject: [PATCH 13/17] repo: allow individual package building --- repo/Dockerfile | 5 ++++- repo/entrypoint.sh | 10 ++++++++++ repo/make.sh | 13 ------------- 3 files changed, 14 insertions(+), 14 deletions(-) create mode 100755 repo/entrypoint.sh delete mode 100755 repo/make.sh diff --git a/repo/Dockerfile b/repo/Dockerfile index 8980d53..35201e0 100644 --- a/repo/Dockerfile +++ b/repo/Dockerfile @@ -5,4 +5,7 @@ RUN apt-get update && apt-get install -y autoconf build-essential libssl-dev pkg pip3 install 'yq==2.12.0' && \ rm -rf /var/lib/apt/lists/* -CMD [ "bash", "/repo/make.sh" ] \ No newline at end of file +ADD *.sh / + +ENTRYPOINT ["bash","/entrypoint.sh"] +CMD ["all"] diff --git a/repo/entrypoint.sh b/repo/entrypoint.sh new file mode 100755 index 0000000..bd958ab --- /dev/null +++ b/repo/entrypoint.sh @@ -0,0 +1,10 @@ +cd /packages +for pkg in "$*" +do + make -j16 build-$pkg +done + +cd /repo +./mkindex.sh + +curl -s http://piston_api:6969/repos -XPOST -d "slug=local&url=file:///repo/index.yaml" diff --git a/repo/make.sh b/repo/make.sh deleted file mode 100755 index bad392e..0000000 --- a/repo/make.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -e - -cd /repo - -# Make packages -pushd ../packages/ -make -j16 -popd - - -# Make repo index - -./mkindex.sh \ No newline at end of file From 70262d8c4b792dcaea021780865761ceee508b57 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 18:29:20 +1300 Subject: [PATCH 14/17] deploy: new repo container takes care of this --- docker-compose.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 509e677..c74a814 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -16,11 +16,7 @@ services: piston_fs_repo: #Temporary solution until CI works build: repo - command: > - bash -c '/repo/make.sh && - curl http://piston_api:6969/repos -XPOST -d "slug=local&url=file:///repo/index.yaml"; - echo -e "\nAn error here is fine, it just means its already added it. Perhaps you restarted this container" - ' + command: ['python'] # Only build python volumes: - ./repo:/repo - ./packages:/packages \ No newline at end of file From 1a7382bb6f24cd4fd888ac6aa05ac779aba248f6 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 19:20:28 +1300 Subject: [PATCH 15/17] pkg(common): Generate test file per version --- packages/.gitignore | 3 ++- packages/common.mk | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/.gitignore b/packages/.gitignore index 2e367bf..5c3f8df 100644 --- a/packages/.gitignore +++ b/packages/.gitignore @@ -1,2 +1,3 @@ build/ -*.pkg.tar.gz \ No newline at end of file +*.pkg.tar.gz +*.tf \ No newline at end of file diff --git a/packages/common.mk b/packages/common.mk index ec069b0..d71d584 100644 --- a/packages/common.mk +++ b/packages/common.mk @@ -34,11 +34,12 @@ name: .NOTPARALLEL: build -build: ${BUILD_DIR} ${PKG_FILE} +build: ${BUILD_DIR} ${PKG_FILE} ${PKG_SLUG}.tf clean: rm -rf ${BUILD_DIR} rm -f ${PKG_FILE} + rm -f ${PKG_SLUG}.tf # mkdir ${BUILD_DIR}: @@ -61,7 +62,8 @@ $(patsubst %.json,%.jq,${INFO_FILE}): echo '.build_platform="$(or ${PLATFORM}, baremetal-$(shell grep -oP "^ID=\K\w+" /etc/os-release ))"' >> $@ $(foreach dep, ${DEPENDENCIES}, echo '.dependencies.$(word 1,$(subst =, ,${dep}))="$(word 2,$(subst =, ,${dep}))"' >> $@) - +${PKG_SLUG}.tf: + cp ${NAME}.test $@ # Helpers %/: %.tar.gz From 89d787cd63f1ebbe0ccb8b81b174b8853592fc82 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 19:30:35 +1300 Subject: [PATCH 16/17] ci(package-pr): automated testing --- .github/workflows/package-pr.yaml | 56 ++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/.github/workflows/package-pr.yaml b/.github/workflows/package-pr.yaml index de2f025..866a1a1 100644 --- a/.github/workflows/package-pr.yaml +++ b/.github/workflows/package-pr.yaml @@ -11,8 +11,8 @@ on: - 'packages/**' jobs: - packages-affected: - name: List affected packages + check-build: + name: Check that package builds runs-on: ubuntu-latest steps: - name: Get PR Commits @@ -21,7 +21,6 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} - name: Check subsystem - if: ${{ success() || failure() }} uses: tim-actions/commit-message-checker-with-regex@v0.3.1 with: commits: ${{ steps.get-pr-commits.outputs.commits }} @@ -33,17 +32,44 @@ jobs: shell: bash run: | COMMITS='${{ steps.get-pr-commits.outputs.commits }}' - PACKAGES=$(echo $COMMITS | jq .[].commit.message -r | grep -oP '^pkg\(\K[^:\h\n]+(?=\))' | sort -u | sed 's/^/* /') - PACKAGES=${PACKAGES//$'%'/'%25'} - PACKAGES=${PACKAGES//$'\n'/'%0A'} - PACKAGES=${PACKAGES//$'\r'/'%0D'} + PACKAGES=$(echo $COMMITS | jq .[].commit.message -r | grep -oP '^pkg\(\K[^:\h\n]+(?=\))' | sort -u) echo "::set-output name=packages::$PACKAGES" - - name: 'Comment PR' - uses: actions/github-script@0.3.0 - if: github.event_name == 'pull_request' - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const { issue: { number: issue_number }, repo: { owner, repo } } = context; - github.issues.createComment({ issue_number, owner, repo, body: "Affected packages:\n${{ steps.get-packages.outputs.packages }}" }); \ No newline at end of file + - name: Checkout + uses: actions/checkout@v2 + + - name: Build docker containers + run: | + docker build -t piston_fs_repo repo + docker build -t piston_api api + + - name: Build Packages + run: | + docker run -v './repo:/repo' -v './packages:/packages' piston_fs_repo ${{ steps.get-packages.outputs.packages }} + + - name: Run tests + run: | + docker run -dp 6969:6969 -v './repo:/repo' --privileged --name api piston_api + echo Waiting for API to start.. + bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:6969/runtimes)" != "200" ]]; do sleep 5; done' + echo Adding local repo + curl -s http://127.0.0.1:6969/repos -XPOST -d "slug=local&url=file:///repo/index.yaml" + echo Testing packages + for pkg in "$(curl -s http://127.0.0.1:6969/repos/local/packages/ | jq '.data.packages[] | "\(.language)/\(.language_version)"' -r)" + do + PKG_SLUG=${pkg/\//-} + PKG_NAME=$(echo $pkg | cut -d'/' -f 1) + PKG_VERSION=$(echo $pkg | cut -d'/' -f 2) + echo Installing ${PKG_SLUG} + curl -sXPOST http://127.0.0.1:6969/repos/local/packages/${pkg} | jq '.language' -r || exit 1 + echo Testing ${PKG_SLUG} (using ${PKG_SLUG}.tf) + TEST_FILE=$(cat ${PKG_SLUG}.tf) + TEST_JSON=`jq -C '.language = "${PKG_NAME}" | .version = "${PKG_VERSION}" | .files=[] | .files[0]={} | .files[0].name="test" | .files[0].name.content="${TEST_FILE}" | .main = "test" | .args = [] | .stdin = "" | .compile_timeout = 10000 | .run_timeout = 3000' <<< '{}'` + curl -sXPOST http://127.0.0.1:6969/jobs -H 'Content-Type: application/json' -d "$TEST_JSON" + done + + + + + + From b410fa8525f7fd13a3becb8f25c985c3de4235f2 Mon Sep 17 00:00:00 2001 From: Thomas Hobson Date: Sun, 28 Feb 2021 19:43:34 +1300 Subject: [PATCH 17/17] ci(package-pr): use absolute paths in docker --- .github/workflows/package-pr.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package-pr.yaml b/.github/workflows/package-pr.yaml index 866a1a1..daf23e8 100644 --- a/.github/workflows/package-pr.yaml +++ b/.github/workflows/package-pr.yaml @@ -45,11 +45,11 @@ jobs: - name: Build Packages run: | - docker run -v './repo:/repo' -v './packages:/packages' piston_fs_repo ${{ steps.get-packages.outputs.packages }} + docker run -v $(pwd)'/repo:/repo' -v $(pwd)'/packages:/packages' piston_fs_repo ${{ steps.get-packages.outputs.packages }} - name: Run tests run: | - docker run -dp 6969:6969 -v './repo:/repo' --privileged --name api piston_api + docker run -dp 6969:6969 -v $(pwd)'/repo:/repo' --privileged --name api piston_api echo Waiting for API to start.. bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:6969/runtimes)" != "200" ]]; do sleep 5; done' echo Adding local repo