hmlongco / Factory

A new approach to Container-Based Dependency Injection for Swift and SwiftUI.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please add action to test linux build

doozMen opened this issue · comments

The file Sources/Factory/Factory/Scopes.swift missesimport CorFoundation import that allows it to build on ubuntu 18. Otherwise you would get error

error: cannot find 'CFAbsoluteTimeGetCurrent' in scope
                return WeakBox(scopeID: scopeID, timestamp: CFAbsoluteTimeGetCurrent(), boxed: instance as AnyObject)
                                                            ^~~~~~~~~~~~~~~~~~~~~~~~

Could you add a swift action to run swift tests on linux so this does not happen anymore. Thanks

I can add the missing import, but I don't have a Linux environment in which I can run tests...

I could help with that and setup a github action so it runs on linux too if you would like that? I just want to avoid going into a PR without discussing first.

It's easy to run on Ubuntu. The following steps are required for the workflow:

steps:
  - name: ☑️ Swift Select
    uses: swift-actions/setup-swift@v1
    with:
        swift-version: 5.6

  - name: ⬇️ Get Sources
    uses: actions/checkout@v3.5.3

  - name: 🍀 Test Package
    run: swift test

@brennobemoura I'm sure the steps are easy for someone who understands them... ;)

@hmlongco, I am available to set up the workflow on Github Actions, if you prefer, to build and test Factory on all PRs.

As a single developer I don't tend to PR my own code. Would this run on GitHub?

Hmm, in this particular situation, things get a bit more complicated. I utilize this as a means of PR validation. While you can set it up to run whenever the main branch is updated, there is a possibility that certain commits might fail during the compilation process.

It's easy to run on Ubuntu. The following steps are required for the workflow:

steps:
  - name: ☑️ Swift Select
    uses: swift-actions/setup-swift@v1
    with:
        swift-version: 5.6

  - name: ⬇️ Get Sources
    uses: actions/checkout@v3.5.3

  - name: 🍀 Test Package
    run: swift test

That's about GitHub Actions for Linux Testing. To ensure this kind of error doesn't happen in the future, it will be ok to have a continuous integration setup that tests the Swift code on a Linux environment every time changes are made.

The proposed by you GitHub Action workflow is a good start. Here's how you @hmlongco can implement it:

Create a new file named .github/workflows/swift_linux.yml in the project root.

Add the following content to this file:

name: Swift on Linux

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: ☑️ Swift Select
      uses: swift-actions/setup-swift@v1
      with:
          swift-version: 5.6

    - name: ⬇️ Get Sources
      uses: actions/checkout@v3.5.3

    - name: 🍀 Test Package
      run: swift test

Don't forget to commit & Push :)

This will create a GitHub Actions workflow that triggers every time there's a push to the main branch.