Skip to content

Commit

Permalink
Merge branch 'main' into add-two-fer
Browse files Browse the repository at this point in the history
  • Loading branch information
meatball133 authored Feb 12, 2024
2 parents 49eb9a8 + 0431038 commit c4c4c92
Show file tree
Hide file tree
Showing 127 changed files with 3,856 additions and 61 deletions.
51 changes: 51 additions & 0 deletions .gdlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
class-definitions-order:
- tools
- classnames
- extends
- docstrings
- signals
- enums
- consts
- exports
- pubvars
- prvvars
- onreadypubvars
- onreadyprvvars
- staticvars
- others
class-load-variable-name: (([A-Z][a-z0-9]*)+|_?[a-z][a-z0-9]*(_[a-z0-9]+)*)
class-name: ([A-Z][a-z0-9]*)+
class-variable-name: _?[a-z][a-z0-9]*(_[a-z0-9]+)*
comparison-with-itself: null
constant-name: _?[A-Z][A-Z0-9]*(_[A-Z0-9]+)*
disable: [
unused-argument,
max-line-length,
max-public-methods,
]
duplicated-load: null
enum-element-name: '[A-Z][A-Z0-9]*(_[A-Z0-9]+)*'
enum-name: ([A-Z][a-z0-9]*)+
excluded_directories: !!set
.git: null
expression-not-assigned: null
function-argument-name: _?[a-z][a-z0-9]*(_[a-z0-9]+)*
function-arguments-number: 10
function-preload-variable-name: ([A-Z][a-z0-9]*)+
function-variable-name: '[a-z][a-z0-9]*(_[a-z0-9]+)*'
load-constant-name: (([A-Z][a-z0-9]*)+|_?[A-Z][A-Z0-9]*(_[A-Z0-9]+)*)
loop-variable-name: _?[a-z][a-z0-9]*(_[a-z0-9]+)*
max-file-lines: 1000
max-line-length: 100
max-public-methods: 20
max-returns: 6
mixed-tabs-and-spaces: null
no-elif-return: null
no-else-return: null
private-method-call: null
signal-name: '[a-z][a-z0-9]*(_[a-z0-9]+)*'
sub-class-name: _?([A-Z][a-z0-9]*)+
tab-characters: 1
trailing-whitespace: null
unnecessary-pass: null
unused-argument: null
14 changes: 5 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Requires scripts:
# - bin/test

name: <track> / Test
name: GDScript / Test

on:
push:
Expand All @@ -23,17 +23,13 @@ on:

jobs:
ci:
runs-on: <image-name>
runs-on: ubuntu-22.04
container:
image: exercism/gdscript-test-runner

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Use <setup tooling>
uses: <action to setup tooling>

- name: Install project dependencies
run: <install dependencies>
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Verify all exercises
run: bin/verify-exercises
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Exercism
Copyright (c) 2021 Exercism

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ 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.
SOFTWARE.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Exercism GDScript Track

[![configlet](https://github.com/exercism/gdscript/workflows/configlet/badge.svg)](https://github.com/exercism/gdscript/actions?query=workflow%3Aconfiglet) [![tests](https://github.com/exercism/gdscript/workflows/test/badge.svg)](https://github.com/exercism/gdscript/actions?query=workflow%3Atest)
[![Configlet](https://github.com/exercism/gdscript/actions/workflows/configlet.yml/badge.svg)](https://github.com/exercism/gdscript/actions/workflows/configlet.yml) [![.github/workflows/test.yml](https://github.com/exercism/gdscript/actions/workflows/test.yml/badge.svg)](https://github.com/exercism/gdscript/actions/workflows/test.yml)

Exercism exercises in GDScript.

## Testing

To test the exercises, run `./bin/test`.
To test the exercises, run `./bin/verify-exercises`.
This command will iterate over all exercises and check to see if their exemplar/example implementation passes all the tests.

### Track linting

[`configlet`](https://exercism.org/docs/building/configlet) is an Exercism-wide tool for working with tracks. You can download it by running:

```shell
$ ./bin/fetch-configlet
./bin/fetch-configlet
```

Run its [`lint` command](https://exercism.org/docs/building/configlet/lint) to verify if all exercises have all the necessary files and if config files are correct:
Expand Down
35 changes: 23 additions & 12 deletions bin/fetch-configlet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,31 @@ $requestOpts = @{
RetryIntervalSec = 1
}

$arch = If ([Environment]::Is64BitOperatingSystem) { "x86-64" } Else { "i386" }
$fileName = "configlet_.+_windows_$arch.zip"

Function Get-DownloadUrl {
$arch = If ([Environment]::Is64BitOperatingSystem) { "x86-64" } Else { "i386" }
$latestUrl = "https://api.github.com/repos/exercism/configlet/releases/latest"
Invoke-RestMethod -Uri $latestUrl -PreserveAuthorizationOnRedirect @requestOpts
| Select-Object -ExpandProperty assets
| Where-Object { $_.browser_download_url -match $FileName }
| Select-Object -ExpandProperty browser_download_url
Invoke-RestMethod -Uri $latestUrl -PreserveAuthorizationOnRedirect @requestOpts `
| Select-Object -ExpandProperty assets `
| Where-Object { $_.name -match "^configlet_.+_windows_${arch}.zip$" } `
| Select-Object -ExpandProperty browser_download_url -First 1
}

$downloadUrl = Get-DownloadUrl
$outputDirectory = "bin"
$outputFile = Join-Path -Path $outputDirectory -ChildPath $fileName
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts
Expand-Archive $outputFile -DestinationPath $outputDirectory -Force
Remove-Item -Path $outputFile
if (!(Test-Path -Path $outputDirectory)) {
Write-Output "Error: no ./bin directory found. This script should be ran from a repo root."
exit 1
}

Write-Output "Fetching configlet..."
$downloadUrl = Get-DownloadUrl
$outputFileName = "configlet.zip"
$outputPath = Join-Path -Path $outputDirectory -ChildPath $outputFileName
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputPath @requestOpts

$configletPath = Join-Path -Path $outputDirectory -ChildPath "configlet.exe"
if (Test-Path -Path $configletPath) { Remove-Item -Path $configletPath }
[System.IO.Compression.ZipFile]::ExtractToDirectory($outputPath, $outputDirectory)
Remove-Item -Path $outputPath

$configletVersion = (Select-String -Pattern "/releases/download/(.+?)/" -InputObject $downloadUrl -AllMatches).Matches.Groups[1].Value
Write-Output "Downloaded configlet ${configletVersion} to ${configletPath}"
42 changes: 24 additions & 18 deletions bin/verify-exercises
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
#!/usr/bin/env bash

# Synopsis:
# Test the track's exercises.
#
# At a minimum, this file must check if the example/exemplar solution of each
# Practice/Concept Exercise passes the exercise's tests.
#
# To check this, you usually have to (temporarily) replace the exercise's solution files
# with its exemplar/example files.
#
# If your track uses skipped tests, make sure to (temporarily) enable these tests
# before running the tests.
#
# The path to the solution/example/exemplar files can be found in the exercise's
# .meta/config.json file, or possibly inferred from the exercise's directory name.
temp_dir_base=$(mktemp -d)
echo $(godot --version)

# Example:
# ./bin/test
run_test() {
slug=$(basename $1)
temp_dir=${temp_dir_base}/${slug}
mkdir -p ${temp_dir}
# Copy relevant files to the temp directory (replace solution with example)
solution_file_name="$(jq -r '.files.solution[0]' $1/.meta/config.json)"
test_file="$1/$(jq -r '.files.test[0]' $1/.meta/config.json)"
example_file="$1/$(jq -r '.files.example[0]' $1/.meta/config.json)"
cp ${test_file} ${temp_dir}
cp ${example_file} "${temp_dir}/${solution_file_name}"
# Run the tests
(cd /opt/test-runner && bin/run.sh $slug $temp_dir $temp_dir) || exit 1
# Check status
test_status="$(jq -r '.status' $temp_dir/results.json)"
if [ "$test_status" != "pass" ]; then
echo "Tests for $slug have failed:"
cat $temp_dir/results.json
exit 1
fi
}

# Verify the Concept Exercises
for concept_exercise_dir in ./exercises/concept/*/; do
if [ -d $concept_exercise_dir ]; then
echo "Checking $(basename "${concept_exercise_dir}") exercise..."
# TODO: run command to verify that the exemplar solution passes the tests
run_test $concept_exercise_dir
fi
done

# Verify the Practice Exercises
for practice_exercise_dir in ./exercises/practice/*/; do
if [ -d $practice_exercise_dir ]; then
echo "Checking $(basename "${practice_exercise_dir}") exercise..."
# TODO: run command to verify that the example solution passes the tests
run_test $practice_exercise_dir
fi
done
Loading

0 comments on commit c4c4c92

Please sign in to comment.