mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-10 20:59:19 +00:00
update
This commit is contained in:
parent
c67c4b7c50
commit
380372c623
20
.github/classroom/checkresult.js
vendored
Normal file
20
.github/classroom/checkresult.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// TODO 判断文件是否存在
|
||||
|
||||
function judge(outputFile) {
|
||||
try {
|
||||
let jsonResult = JSON.parse(outputFile);
|
||||
let points = {};
|
||||
jsonResult.exercises.forEach(({ name, result }) => {
|
||||
if (result) {
|
||||
points[name] = [1,1]
|
||||
} else {
|
||||
points[name] = [0,1]
|
||||
}
|
||||
})
|
||||
return points;
|
||||
} catch(e) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.judge = judge;
|
||||
411
.github/result/check_result.json
vendored
Normal file
411
.github/result/check_result.json
vendored
Normal file
@ -0,0 +1,411 @@
|
||||
{
|
||||
"exercises": [
|
||||
{
|
||||
"name": "intro2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "move_semantics1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "functions3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "primitive_types2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "options2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "hashmaps1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "strings2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "structs2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "variables5",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "generics2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "variables2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "variables1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "functions4",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "move_semantics2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "primitive_types3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "options3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "variables6",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "strings3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "traits1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "variables3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "traits4",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "functions5",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "structs3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "strings4",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "errors1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "move_semantics3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "primitive_types4",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "functions1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "traits2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "variables4",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "if1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "traits5",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "modules1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "errors2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "enums1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "move_semantics4",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "primitive_types5",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "lifetimes2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "traits3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "functions2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "if2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "modules2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "errors3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "move_semantics5",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "enums2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "lifetimes3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "primitive_types6",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "tests2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "iterators1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "modules3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "if3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "iterators4",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "tests1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "enums3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "move_semantics6",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "vecs1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "tests3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "iterators2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "quiz1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "tests4",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "vecs2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "strings1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "cow1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "structs1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "primitive_types1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "macros1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "macros3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "threads2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "errors4",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "macros4",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "errors5",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "macros2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "threads3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "using_as",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "from_into",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "from_str",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "try_from_into",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "as_ref_mut",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "tests5",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "tests6",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "tests7",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "tests8",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "hashmaps2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "tests9",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "generics1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "lifetimes1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "quiz2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "box1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "options1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "arc1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "clippy1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "clippy3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "quiz3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "clippy2",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "rc1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "iterators5",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "iterators3",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "threads1",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "errors6",
|
||||
"result": false
|
||||
},
|
||||
{
|
||||
"name": "hashmaps3",
|
||||
"result": false
|
||||
}
|
||||
],
|
||||
"user_name": null,
|
||||
"statistics": {
|
||||
"total_exercations": 100,
|
||||
"total_succeeds": 0,
|
||||
"total_failures": 100,
|
||||
"total_time": 3
|
||||
}
|
||||
}
|
||||
76
.github/workflows/rust.yml
vendored
76
.github/workflows/rust.yml
vendored
@ -1,37 +1,71 @@
|
||||
name: Rustlings Tests
|
||||
name: GitHub Classroom Workflow
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
# - '.github/**'
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
TZ: Asia/Shanghai # 设置时区
|
||||
|
||||
jobs:
|
||||
fmt:
|
||||
build:
|
||||
name: Autograding
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
details: ${{ steps.autograding.outputs.details }}
|
||||
points: ${{ steps.autograding.outputs.points}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Run tests
|
||||
run: cargo test --test cicv --verbose
|
||||
- uses: yfblock/os-autograding@master
|
||||
id: autograding
|
||||
with:
|
||||
outputFile: .github/result/check_result.json
|
||||
deploy:
|
||||
name: Deploy to pages
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
continue-on-error: true
|
||||
with:
|
||||
components: rustfmt
|
||||
- uses: DavidAnson/markdownlint-cli2-action@v9
|
||||
ref: 'gh-pages'
|
||||
- name: Save Log File
|
||||
run: |
|
||||
mkdir autograding_logs
|
||||
cd autograding_logs
|
||||
if [ -f "../latest.json" ]; then
|
||||
cp ../latest.json older.json
|
||||
else
|
||||
echo "{}" > older.json
|
||||
fi
|
||||
FILE_NAME=`date +%Y_%m_%d_%H_%M_%S`.txt
|
||||
echo -ne "${{ needs.build.outputs.details }}\n" > $FILE_NAME
|
||||
echo -ne "Points: ${{ needs.build.outputs.points }}" >> $FILE_NAME
|
||||
cat older.json | jq ".default |= \"$FILE_NAME\"" > latest.json
|
||||
rm older.json
|
||||
echo -ne "# Got Points\n" > README.md
|
||||
echo "" >> README.md
|
||||
- name: Make points svg
|
||||
uses: markpatterson27/points-bar@v1
|
||||
with:
|
||||
globs: "exercises/**/*.md"
|
||||
- name: Run cargo fmt
|
||||
run: |
|
||||
cargo fmt --all -- --check
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: swatinem/rust-cache@v2
|
||||
- name: Run cargo test
|
||||
run: |
|
||||
cargo test
|
||||
points: '${{ needs.build.outputs.points }}'
|
||||
path: 'autograding_logs/points-badge.svg'
|
||||
type: 'badge'
|
||||
- name: GitHub Pages
|
||||
uses: crazy-max/ghaction-github-pages@v3
|
||||
with:
|
||||
target_branch: gh-pages
|
||||
build_dir: autograding_logs
|
||||
keep_history: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
88
.github/workflows/web.yml
vendored
88
.github/workflows/web.yml
vendored
@ -1,88 +0,0 @@
|
||||
# Workflow to build your docs with oranda (and mdbook)
|
||||
# and deploy them to Github Pages
|
||||
name: Web
|
||||
|
||||
# We're going to push to the gh-pages branch, so we need that permission
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
# What situations do we want to build docs in?
|
||||
# All of these work independently and can be removed / commented out
|
||||
# if you don't want oranda/mdbook running in that situation
|
||||
on:
|
||||
# Check that a PR didn't break docs!
|
||||
#
|
||||
# Note that the "Deploy to Github Pages" step won't run in this mode,
|
||||
# so this won't have any side-effects. But it will tell you if a PR
|
||||
# completely broke oranda/mdbook. Sadly we don't provide previews (yet)!
|
||||
pull_request:
|
||||
|
||||
# Whenever something gets pushed to main, update the docs!
|
||||
# This is great for getting docs changes live without cutting a full release.
|
||||
#
|
||||
# Note that if you're using cargo-dist, this will "race" the Release workflow
|
||||
# that actually builds the Github Release that oranda tries to read (and
|
||||
# this will almost certainly complete first). As a result you will publish
|
||||
# docs for the latest commit but the oranda landing page won't know about
|
||||
# the latest release. The workflow_run trigger below will properly wait for
|
||||
# cargo-dist, and so this half-published state will only last for ~10 minutes.
|
||||
#
|
||||
# If you only want docs to update with releases, disable this, or change it to
|
||||
# a "release" branch. You can, of course, also manually trigger a workflow run
|
||||
# when you want the docs to update.
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
# Whenever a workflow called "Release" completes, update the docs!
|
||||
#
|
||||
# If you're using cargo-dist, this is recommended, as it will ensure that
|
||||
# oranda always sees the latest release right when it's available. Note
|
||||
# however that Github's UI is wonky when you use workflow_run, and won't
|
||||
# show this workflow as part of any commit. You have to go to the "actions"
|
||||
# tab for your repo to see this one running (the gh-pages deploy will also
|
||||
# only show up there).
|
||||
workflow_run:
|
||||
workflows: [ "Release" ]
|
||||
types:
|
||||
- completed
|
||||
|
||||
# Alright, let's do it!
|
||||
jobs:
|
||||
web:
|
||||
name: Build and deploy site and docs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Setup
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: swatinem/rust-cache@v2
|
||||
|
||||
# If you use any mdbook plugins, here's the place to install them!
|
||||
|
||||
# Install and run oranda (and mdbook)
|
||||
# This will write all output to ./public/ (including copying mdbook's output to there)
|
||||
- name: Install and run oranda
|
||||
run: |
|
||||
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/oranda/releases/download/v0.3.1/oranda-installer.sh | sh
|
||||
oranda build
|
||||
|
||||
# Deploy to our gh-pages branch (creating it if it doesn't exist)
|
||||
# the "public" dir that oranda made above will become the root dir
|
||||
# of this branch.
|
||||
#
|
||||
# Note that once the gh-pages branch exists, you must
|
||||
# go into repo's settings > pages and set "deploy from branch: gh-pages"
|
||||
# the other defaults work fine.
|
||||
- name: Deploy to Github Pages
|
||||
uses: JamesIves/github-pages-deploy-action@v4.4.1
|
||||
# ONLY if we're on main (so no PRs or feature branches allowed!)
|
||||
if: ${{ github.ref == 'refs/heads/main' }}
|
||||
with:
|
||||
branch: gh-pages
|
||||
# Gotta tell the action where to find oranda's output
|
||||
folder: public
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
single-commit: true
|
||||
Loading…
x
Reference in New Issue
Block a user