Skip to content

Commit

Permalink
Compile code samples
Browse files Browse the repository at this point in the history
  • Loading branch information
shaedrich authored Jun 5, 2024
1 parent caae6e2 commit 963a676
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .ci-scripts/check-ci-samples.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -e
set -u

cd ./code-samples/
files=$(ls | wc -l)
echo "Check $files files …"
failedFiles=()
notRunnable=0
i=0
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
done
runnableFiles=$((files-notRunnable))
if [ "${#failedFiles[@]}" != 0 ]; then
echo -e "\e[1;31m💥 ${#failedFiles[@]}/$runnableFiles file(s) ($files total) had errors\e[0m"
exit 1
else
echo -e "\e[1;32m🎉 All $files files ($runnableFiles runnable) were checked successfully\e[0m"
exit 0
fi
17 changes: 17 additions & 0 deletions .ci-scripts/setup-ponyc.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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
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

0 comments on commit 963a676

Please sign in to comment.