Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4/?] Add ability to run code examples in the playground: Get pony snippets tested with ponyc at CI time #551

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
35 changes: 35 additions & 0 deletions .ci-scripts/check-code-samples.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

#set -e
set -u

cd ./code-samples/
files=$(ls | wc -l)
echo "Check $files files …"
failedFiles=()
i=0
$HOME/.local/share/ponyup/bin/ponyc
ls -l
for file in *.pony; do
((i++))
percentage=$(((i*100)/files))
echo -e "#$i Test $file … ($i/$files \u2192 $percentage %)"
#docker run -v $(pwd):/src/main docker://ghcr.io/ponylang/ponyc:latest
#ponyc "./code-samples/$file"
#$HOME/.local/share/ponyup/bin/ponyc "${{ github.workspace }}/code-samples/$file"
#$HOME/.local/share/ponyup/bin/ponyc #"$GITHUB_WORKSPACE/code-samples/$file"
#if [ $? -eq 0 ]; then
if [ -f "$file.ll" ] && [ -f "$file.s" ]; then
echo -e "\e[1;32m\u2705 File could be compiled successfully\e[0m"
else
echo -e "\e[1;31m\u274C File compilation failed\e[0m"
failedFiles+=(file)
fi
done
if [ "${#failedFiles[@]}" != 0 ]; then
echo -e "\e[1;31m💥 ${#failedFiles[@]}/$files file(s) had errors\e[0m"
exit 1
else
echo -e "\e[1;32m🎉 All $files files were checked successfully\e[0m"
exit 0
fi
22 changes: 22 additions & 0 deletions .ci-scripts/setup-ponyc-docker.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e
set -u

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

docker pull docker://ghcr.io/ponylang/ponyc:latest
11 changes: 11 additions & 0 deletions .ci-scripts/setup-ponyc.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e
set -u

export SHELL=/bin/bash

sh -c "$(curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/ponylang/ponyup/latest-release/ponyup-init.sh)"
export PATH=$HOME/.local/share/ponyup/bin:$PATH
ponyup update ponyc release
export PATH=$HOME/.local/share/ponyup/bin/ponyc:$PATH
17 changes: 17 additions & 0 deletions .github/workflows/check-code-samples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Check code samples

on:
pull_request:
push:

jobs:
check-code-samples:
name: Check code samples
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Setup ponyc
run: ${GITHUB_WORKSPACE}/.ci-scripts/setup-ponyc.bash
- name: Check code samples
run: ${GITHUB_WORKSPACE}/.ci-scripts/check-code-samples.bash
Loading