-
Notifications
You must be signed in to change notification settings - Fork 0
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
10 changed files
with
160 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.repository == 'codewars/forth' }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
push: false | ||
# Make the image available in next step | ||
load: true | ||
tags: ghcr.io/codewars/forth:latest | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Run Passing Example | ||
run: bin/run passing | ||
|
||
- name: Report Image Size | ||
run: | | ||
echo "## Image Size" >> $GITHUB_STEP_SUMMARY | ||
docker image inspect --format '{{.Size}}' ghcr.io/codewars/forth:latest | numfmt --to=si --suffix=B >> $GITHUB_STEP_SUMMARY |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Build and push a Docker image to GitHub Container Registry when | ||
# a new tag is pushed. | ||
name: Push Image | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
|
||
jobs: | ||
build-and-push-image: | ||
if: ${{ github.repository == 'codewars/forth' }} | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push image | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
push: true | ||
tags: | | ||
ghcr.io/${{ github.repository_owner }}/forth:latest | ||
ghcr.io/${{ github.repository_owner }}/forth:${{ github.ref_name }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM ubuntu:18.04 | ||
|
||
ENV LANG=C.UTF-8 | ||
RUN set -ex; \ | ||
apt-get update; \ | ||
apt-get install -y --no-install-recommends \ | ||
# Install GNU Forth Language Environment 0.7.3 | ||
# https://packages.ubuntu.com/bionic/gforth | ||
gforth \ | ||
wget \ | ||
ca-certificates \ | ||
; \ | ||
rm -rf /var/lib/apt/lists/*; | ||
|
||
RUN set -ex; \ | ||
useradd --create-home codewarrior; \ | ||
mkdir /workspace; \ | ||
chown codewarrior:codewarrior /workspace; | ||
|
||
USER codewarrior | ||
ENV USER=codewarrior \ | ||
HOME=/home/codewarrior | ||
WORKDIR /workspace | ||
|
||
# `ttester-codewars.4th` contains words to make test output in Codewars format. | ||
RUN wget -q https://raw.githubusercontent.com/codewars/ttester-codewars/v0.0.4/ttester-codewars.4th |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Codewars | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Forth | ||
|
||
Container image for Forth used by CodeRunner. | ||
|
||
## Usage | ||
|
||
Use the `bin/run` to test examples in `examples/`. | ||
|
||
```bash | ||
./bin/run passing | ||
``` | ||
|
||
## Examples | ||
|
||
- `passing`: a passing example | ||
|
||
## Building | ||
|
||
```bash | ||
docker build -t ghcr.io/codewars/forth:latest . | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
W=/workspace | ||
FILES="preloaded.4th solution.4th ttester-codewars.4th tests.4th" | ||
# Create container | ||
C=$(docker container create --rm -w $W ghcr.io/codewars/forth:latest sh -c "gforth $FILES -e bye") | ||
|
||
# Copy files from the current directory | ||
docker container cp examples/${1:-passing}/. $C:$W | ||
|
||
# Run tests | ||
docker container start --attach $C |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
\ preloaded.4th is loaded before solution.4th |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
: solution ( u1|n1 u2|n2 -- u3|n3 ) + ; \ Addition |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
s" solution" describe#{ | ||
s" returns sum" it#{ | ||
<{ 1 1 solution -> 2 }> | ||
}# | ||
}# |