Skip to content

Commit

Permalink
init: create an example repo using GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
everythingfunctional committed Nov 9, 2022
0 parents commit 08036b4
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build and Test

on: [push, pull_request]


jobs:
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macOS-latest, windows-latest]
env:
GCC_V: 12

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

- uses: fortran-lang/setup-fpm@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Dependencies Ubuntu
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt install -y gfortran-${GCC_V}
sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} 100
- name: Install Dependencies MacOS
if: contains(matrix.os, 'macos')
run: |
brew install gcc@${GCC_V}
sudo ln -s $(which gfortran-${GCC_V}) $(dirname $(which gfortran-${GCC_V}))/gfortran
- name: Install Dependencies Windows
if: contains(matrix.os, 'windows')
uses: msys2/setup-msys2@v2
with:
update: true
path-type: inherit
install: >-
mingw-w64-x86_64-gcc-fortran
- name: Build and Test Linux and MacOS
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos')
run: |
which gfortran
gfortran --version
fpm test
- name: Build and Test Windows
if: contains(matrix.os, 'windows')
shell: msys2 {0}
run: |
which gfortran
gfortran --version
fpm test
47 changes: 47 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build and Deploy Documentation

on: [push, pull_request]

jobs:
documentation:
runs-on: ubuntu-22.04

env:
FC: gfortran
GCC_V: 12

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

- name: Install Dependencies Ubuntu
run: |
sudo apt-get update
sudo apt install -y gfortran-${GCC_V} python3-dev graphviz
sudo pip install ford markdown==3.3.4
- name: Build Developer Documenation
run: |
ford doc/ford-front-matter.md
- name: Upload Documentation
uses: actions/upload-artifact@v2
with:
name: documentation
path: doc/ford_site
if-no-files-found: error

- name: Broken Link Check
if: ${{ github.ref == 'refs/heads/main'}}
uses: technote-space/broken-link-checker-action@v1
with:
TARGET: file://${{ github.workspace }}/ford_site/index.html
RECURSIVE: true
ASSIGNEES: ${{ github.actor }}

- name: Deploy API Documentation
uses: JamesIves/[email protected]
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
branch: gh-pages
folder: doc/ford_site
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
doc/ford_site
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ci-example

A simple, contrived project for demonstrating use of the GitHub CI features for a Fortran project.
23 changes: 23 additions & 0 deletions doc/ford-front-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
project: CI-Example
summary: A simple, contrived project for demonstrating use of the GitHub CI features for a Fortran project.
email: [email protected]
src_dir: ../src
exclude_dir: ../doc
preprocessor: gfortran -E
display: public
protected
private
sort: permission-alpha
output_dir: ../doc/ford_site
graph: true
md_extensions: markdown.extensions.toc
...

Welcome to the Fortran CI Example.

## How to Read This Documentation

The listings below are not exhaustive.
To see the full listings use the links at the top of the page.
Also, if you know what you're looking for, there is a search bar in the top right.
6 changes: 6 additions & 0 deletions fpm.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name = "ci-example"
version = "0.1.0"
license = "MIT"
author = "Brad Richardson"
maintainer = "[email protected]"
copyright = "Copyright 2022, Brad Richardson"
14 changes: 14 additions & 0 deletions src/ci-example.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module ci_example
implicit none
private

public :: create_greeting
contains
pure function create_greeting(name) result(greeting)
!! Given a [name], construct a [greeting] for them
character(len=*), intent(in) :: name
character(len=:), allocatable :: greeting

greeting = "Hello, " // name // "!"
end function
end module
16 changes: 16 additions & 0 deletions test/main.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
program test
use ci_example, only: create_greeting

implicit none

character(len=*), parameter :: name = "World"
character(len=*), parameter :: expected = "Hello, " // name // "!"
character(len=:), allocatable :: greeting

greeting = create_greeting(name)
if (greeting == expected) then
print *, "Test passed!"
else
error stop "Test failed! Expected '" // expected // "' but got '" // greeting // "'"
end if
end program

0 comments on commit 08036b4

Please sign in to comment.