Skip to content

Commit

Permalink
Merge pull request #187 from H1ghBre4k3r/fix-docker-build
Browse files Browse the repository at this point in the history
fix(ci): adjust rust version in docker
  • Loading branch information
H1ghBre4k3r authored Jan 15, 2025
2 parents 280d1f2 + 1562777 commit 1f6e636
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 45 deletions.
62 changes: 34 additions & 28 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,44 @@ name: Docker
on:
push:
branches:
- main
- main
pull_request:
workflow_dispatch:

jobs:
build-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/H1ghBre4k3r/y-lang
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha
- name: Build and Push image
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64/v8
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to GHCR
uses: docker/login-action@v1
if: ${{ github.ref_name == 'main' }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/H1ghBre4k3r/y-lang
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha
- name: Build and Push image
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64/v8
push: ${{ github.ref_name == 'main' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG RUSTVERSION=1.67
ARG RUSTVERSION=1.84
ARG DEBIANVERSION=bullseye

FROM --platform=$BUILDPLATFORM rust:${RUSTVERSION}-${DEBIANVERSION} AS builder
Expand Down
10 changes: 8 additions & 2 deletions src/ast/fn_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@ impl FnDef<()> {
let mut inner = pair.into_inner();

let Some(param_list) = inner.next() else {
error!("Expected param list in function definition at {}:{}", line, col);
error!(
"Expected param list in function definition at {}:{}",
line, col
);
std::process::exit(-1);
};
let param_list = Self::from_param_list(param_list, file);

let Some(type_annotation) = inner.next() else {
error!("Expected return type annotation in function definition at {}:{}", line, col);
error!(
"Expected return type annotation in function definition at {}:{}",
line, col
);
std::process::exit(-1);
};
let type_annotation = TypeAnnotation::from_pair(type_annotation, file);
Expand Down
4 changes: 3 additions & 1 deletion src/bin/why/commands/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ fn create_file(base: &str, file: &File) -> Result<(), SetupError> {
debug!("creating file '{path}'");

let Ok(mut file_to_write) = std::fs::File::create(&path) else {
return Err(SetupError::FileError(format!("Failed to create file '{path}'")));
return Err(SetupError::FileError(format!(
"Failed to create file '{path}'"
)));
};

if file_to_write.write_all(file.contents()).is_err() {
Expand Down
10 changes: 6 additions & 4 deletions src/compiler/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,18 +1080,20 @@ impl Scope {
return;
}

let VariableType::Func { params, .. }= &ident.info._type else {
let VariableType::Func { params, .. } = &ident.info._type else {
unreachable!("Trying to call a non-function expression");
};

for (index, param) in call.params.iter().enumerate() {
// if the type of the parameter is a reference, we need to load the address of it
if let VariableType::Reference(_) = params[index] {
let Expression::Ident(Ident { value, info, ..}) = &call.params[index] else {
unimplemented!("Passing non-identifiers as references is currently not supported!");
let Expression::Ident(Ident { value, info, .. }) = &call.params[index] else {
unimplemented!(
"Passing non-identifiers as references is currently not supported!"
);
};

let Some(Variable { offset, ..}) = self.variables.get(value) else {
let Some(Variable { offset, .. }) = self.variables.get(value) else {
unreachable!()
};

Expand Down
2 changes: 1 addition & 1 deletion src/loader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ pub fn load_modules(
let Ok(file_content) = std::fs::read_to_string(&file) else {
return Err(Box::new(FileLoadError {
message: format!("Could not load module: '{file}'"),
position: import.position.clone()
position: import.position.clone(),
}));
};

Expand Down
28 changes: 20 additions & 8 deletions src/typechecker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ impl Typechecker {
Statement::Intrinsic(Intrinsic::Definition(definition)) => {
let Definition { value, ident, .. } = definition;

let Expression::FnDef(FnDef { params, type_annotation , position, ..}) = value else {
let Expression::FnDef(FnDef {
params,
type_annotation,
position,
..
}) = value
else {
continue;
};

Expand Down Expand Up @@ -175,7 +181,7 @@ impl Typechecker {
return Ok(CompilerDirective {
directive: Expression::Binary(directive),
statement: None,
position: position.to_owned()
position: position.to_owned(),
});
};

Expand Down Expand Up @@ -207,10 +213,10 @@ impl Typechecker {
fn check_import(&self, import: &Import, scope: &mut TypeScope) -> TResult<Import> {
let Import { position, path } = import;
let Some(module) = self.modules.get(path) else {
return Err(TypeError {
message: format!("Could not import module '{path}'"),
position: position.clone()
});
return Err(TypeError {
message: format!("Could not import module '{path}'"),
position: position.clone(),
});
};

let imports = module.exports.flatten();
Expand Down Expand Up @@ -719,7 +725,8 @@ impl Typechecker {
let Ok(return_type) = block.info._type.convert_to(&type_annotation) else {
return Err(TypeError {
message: format!(
"Expected return type of '{type_annotation}' but got '{}'", block.info._type
"Expected return type of '{type_annotation}' but got '{}'",
block.info._type
),
position: fn_def.position.clone(),
});
Expand Down Expand Up @@ -788,7 +795,12 @@ impl Typechecker {
});
};

let VariableType::Func { params, return_type, .. } = fn_def.clone() else {
let VariableType::Func {
params,
return_type,
..
} = fn_def.clone()
else {
return Err(TypeError {
message: format!("Trying to call an invalid function '{ident}'"),
position: fn_call.position.clone(),
Expand Down

0 comments on commit 1f6e636

Please sign in to comment.