Commit 74856fbb authored by Ayres, Andrew's avatar Ayres, Andrew
Browse files

move to new template, add code repo, add build

parent 4dc5b359
Loading
Loading
Loading
Loading

.editorconfig

deleted100644 → 0
+0 −26
Original line number Diff line number Diff line
root = true

[*]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
indent_size = 2
indent_style = space
max_line_length = 100  # Please keep this in sync with bin/lesson_check.py!
trim_trailing_whitespace = false  # keep trailing spaces in markdown - 2+ spaces are translated to a hard break (<br/>)

[*.r]
max_line_length = 80

[*.py]
indent_size = 4
indent_style = space
max_line_length = 79

[*.sh]
end_of_line = lf

[Makefile]
indent_style = tab

.github/ISSUE_TEMPLATE.md

deleted100644 → 0
+0 −21
Original line number Diff line number Diff line
<details>
<summary><strong>Instructions</strong></summary>

Thanks for contributing! :heart:

If this contribution is for instructor training, please email the link to this contribution to
checkout@carpentries.org so we can record your progress. You've completed your contribution
step for instructor checkout by submitting this contribution!

If this issue is about a specific episode within a lesson, please provide its link or filename.

Keep in mind that **lesson maintainers are volunteers** and it may take them some time to
respond to your contribution. Although not all contributions can be incorporated into the lesson
materials, we appreciate your time and effort to improve the curriculum. If you have any questions
about the lesson maintenance process or would like to volunteer your time as a contribution
reviewer, please contact The Carpentries Team at team@carpentries.org.

You may delete these instructions from your comment.

\- The Carpentries
</details>

.github/PULL_REQUEST_TEMPLATE.md

deleted100644 → 0
+0 −19
Original line number Diff line number Diff line
<details>
<summary><strong>Instructions</strong></summary>

Thanks for contributing! :heart:

If this contribution is for instructor training, please email the link to this contribution to
instructor.training@carpentries.org so we can record your progress. You've completed your contribution
step for instructor checkout by submitting this contribution!

Keep in mind that **lesson maintainers are volunteers** and it may take them some time to
respond to your contribution. Although not all contributions can be incorporated into the lesson
materials, we appreciate your time and effort to improve the curriculum. If you have any questions
about the lesson maintenance process or would like to volunteer your time as a contribution
reviewer, please contact The Carpentries Team at team@carpentries.org.

You may delete these instructions from your comment.

\- The Carpentries
</details>

.github/workflows/template.yml

deleted100644 → 0
+0 −185
Original line number Diff line number Diff line
name: Test template
on:
  push:
    branches: gh-pages
  pull_request:
jobs:
  check-template:
    name: ${{ matrix.lesson-name }} (${{ matrix.os-name }})
    if: github.repository == 'carpentries/styles'
    runs-on: ${{ matrix.os }}
    continue-on-error: ${{ matrix.experimental }}
    strategy:
      fail-fast: false
      matrix:
        lesson: [swcarpentry/shell-novice, datacarpentry/r-intro-geospatial, librarycarpentry/lc-git]
        os: [ubuntu-20.04, macos-latest, windows-latest]
        experimental: [false]
        include:
          - os: ubuntu-20.04
            os-name: Linux
          - os: macos-latest
            os-name: macOS
          - os: windows-latest
            os-name: Windows
          - lesson: swcarpentry/shell-novice
            lesson-name: (SWC) Shell novice
          - lesson: datacarpentry/r-intro-geospatial
            lesson-name: (DC) R Intro Geospatial
          - lesson: librarycarpentry/lc-git
            lesson-name: (LC) Intro to Git
          - lesson: datacarpentry/astronomy-python
            lesson-name: (DC) Foundations of Astronomical Data Science
            experimental: true
            os: ubuntu-20.04
            os-name: Linux
          - lesson: carpentries/lesson-example
            lesson-name: (CP) Lesson Example
            experimental: false
            os: ubuntu-20.04
            os-name: Linux
    defaults:
      run:
        shell: bash # forces 'Git for Windows' on Windows
    env:
      RSPM: 'https://packagemanager.rstudio.com/cran/__linux__/focal/latest'
    steps:
      - name: Set up Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: '3.0'
          bundler-cache: true

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.x'

      - name: Install GitHub Pages, Bundler, and kramdown gems
        run: |
          gem install github-pages bundler kramdown kramdown-parser-gfm

      - name: Install Python modules
        run: |
          if [[ $RUNNER_OS == macOS || $RUNNER_OS == Linux ]]; then
            python3 -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
          elif [[ $RUNNER_OS == Windows ]]; then
            python -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
          fi

      - name: Checkout the ${{ matrix.lesson }} lesson
        uses: actions/checkout@master
        with:
          repository: ${{ matrix.lesson }}
          path: lesson
          fetch-depth: 0

      - name: Sync lesson with carpentries/styles
        working-directory: lesson
        run: |
          echo "::group::Fetch Styles"
          if [[ -n "${{ github.event.pull_request.number }}" ]]
          then
            ref="refs/pull/${{ github.event.pull_request.number }}/head"
          else
            ref="gh-pages"
          fi

          git config --global user.email "team@carpentries.org"
          git config --global user.name "The Carpentries Bot"

          git remote add styles https://github.com/carpentries/styles.git
          git fetch styles $ref:styles-ref
          echo "::endgroup::"
          echo "::group::Synchronize Styles"
          # Sync up only if necessary
          if [[ $(git rev-list --count HEAD..styles-ref) != 0 ]]
          then

            # The merge command below might fail for lessons that use remote theme
            # https://github.com/carpentries/carpentries-theme
            echo "Testing merge using recursive strategy, accepting upstream changes without committing"
            if ! git merge -s recursive -Xtheirs --no-commit styles-ref
            then

              # Remove "deleted by us, unmerged" files from the staging area.
              # these are the files that were removed from the lesson
              # but are still present in the carpentries/styles repo
              echo "Removing previously deleted files"
              git rm $(git diff --name-only --diff-filter=DU)

              # If there are still "unmerged" files,
              # let's raise an error and look into this more closely
              if [[ -n $(git diff --name-only --diff-filter=U) ]]
              then
                echo "There were unmerged files in ${{ matrix.lesson-name }}:"
                echo "$(git diff --compact-summary --diff-filter=U)"
                exit 1
              fi
            fi

            echo "Committing changes"
            git commit -m "Sync lesson with carpentries/styles"
          fi
          echo "::endgroup::"

      - name: Look for R-markdown files
        id: check-rmd
        working-directory: lesson
        run: |
          echo "count=$(shopt -s nullglob; files=($(find . -iname '*.Rmd')); echo ${#files[@]})" >> $GITHUB_OUTPUT

      - name: Set up R
        if: steps.check-rmd.outputs.count != 0
        uses: r-lib/actions/setup-r@v2
        with:
          use-public-rspm: true
          install-r: false

      - name: Install needed packages
        if: steps.check-rmd.outputs.count != 0
        working-directory: lesson
        run: |
          source('bin/dependencies.R')
          install_required_packages(.libPaths()[1])
        shell: Rscript {0}

      - name: Query dependencies
        if: steps.check-rmd.outputs.count != 0
        working-directory: lesson
        run: |
          source('bin/dependencies.R')
          deps <- identify_dependencies()
          create_description(deps)
          use_bioc_repos()
          saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
          writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
        shell: Rscript {0}

      - name: Restore Package Cache
        if: runner.os != 'Windows' && steps.check-rmd.outputs.count != 0
        uses: actions/cache@v2
        with:
          path: ${{ env.R_LIBS_USER }}
          key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
          restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

      - name: Install stringi from source
        if: runner.os == 'Linux' && steps.check-rmd.outputs.count != 0
        run: install.packages('stringi', repos='https://cloud.r-project.org')
        shell: Rscript {0}

      - name: Install system dependencies for R packages
        if: runner.os == 'Linux' && steps.check-rmd.outputs.count != 0
        working-directory: lesson
        run: |
          while read -r cmd
          do
            eval sudo $cmd || echo "Nothing to update"
          done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')

      - run: make site
        working-directory: lesson

      - run: make lesson-check-all
        working-directory: lesson
+0 −90
Original line number Diff line number Diff line
name: Weekly Styles Update
on:
  workflow_dispatch:
    inputs:
      name:
        description: 'Person who triggered the workflow'
        required: true
        default: 'scheduled run'
  schedule:
    # Run every Wednesday
    - cron: '0 0 * * 3'

jobs:
  check-token:
    name: "Check STYLES_WORKFLOW token"
    runs-on: ubuntu-latest
    if: ${{ github.repository == 'carpentries/lesson-example' }}
    outputs:
      wf: ${{ steps.validate.outputs.wf }}
      repo: ${{ steps.validate.outputs.repo }}
    steps:
      - name: "validate token"
        id: validate
        uses: carpentries/actions/check-valid-credentials@main
        with:
          token: ${{ secrets.STYLES_WORKFLOW }}

  bad-token:
    name: "Invalid/Missing Token"
    runs-on: ubuntu-latest
    needs: check-token
    if: ${{ needs.check-token.outputs.wf != 'true' && github.repository == 'carpentries/lesson-example' }}
    steps:
      - name: "Instructions to create a new token"
        run: |
          printf "::warning::The STYLES_WORKFLOW secret is missing, invalid, "\
          "or does not have the right scope to update workflows.\n"\
          "If you want to have automated pull request updates to your workflows, "\
          "you will need to generate a new token by visiting "\
          "https://github.com/settings/tokens/new?scopes=repo,workflow&description=Styles%%20Token\n"\
          "Once you have created the token, go to "\
          "https://github.com/${{ github.repository }}/settings/secrets/actions/STYLES_WORKFLOW "\
          "to update it."

  update-styles:
    runs-on: ubuntu-latest
    name: Styles Update
    needs: check-token
    if: ${{ needs.check-token.outputs.wf == 'true' && github.repository == 'carpentries/lesson-example' }}
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Record Date
        id: today
        run: |
          echo "::set-output name=date::$(date -I)"
          echo "::set-output name=min::$(date +%Y-%m-%d-%H-%M)"

      - name: Sync lesson with carpentries/styles
        id: update
        uses: carpentries/actions/update-styles@main
        env:
          LESSON: "Lesson Example"
          REF: ${{ github.ref }}
        with:
          commit: true

      - name: Create Pull Request
        id: cpr
        if: ${{ steps.update.outputs.update == 'true' }}
        uses: peter-evans/create-pull-request@v3.10.0
        with:
          token: ${{ secrets.STYLES_WORKFLOW}}
          commit-message: "[actions] Sync lesson with carpentries/styles"
          branch: "update-styles-${{ steps.today.outputs.min }}"
          delete-branch: true
          title: "Update Styles (${{ steps.today.outputs.date }} via ${{ github.event.inputs.name }})"
          body: |
            Update styles repository. Please inspect the changes to make sure there are no conflicts with your lesson.

            - Auto-generated by [create-pull-request][1]

            [1]: https://github.com/peter-evans/create-pull-request
          labels: "type:template and tools"
          # NOTE: This tag is repository-specific
          team-reviewers: core-team-curriculum
          draft: false
Loading